The command-line examples that follow work on Workstation Pro.

Commands Related to Image

  • When you build a new image, to pull the base image from a private Docker registry successfully, either use the vctl login command to log in to the private Docker registry first or use the --credential option to pass a JSON file that stores credentials to vctl build command for registry authentication. For example:
    1. Encode your Docker registry username and password in base64 with the following command:

      echo -n USER:PASSWORD | base64

    2. Create a config.json file with your Docker registry URL and the base64 encoded string generated in step 1.
      {
                                 "auths": {
                                                "https://index.docker.io/v2/": {
                                                               "auth": "xxxxxxxxxxxxxxx"
                                               }
                                  }
      }
      
    3. Build the new image whose base image is in a private Docker registry, by passing the JSON file to vctl build command:

      vctl build --file Dockerfile --tag docker.io/mynamespace/myrepo:1.0 --credential config.json .

Commands Related to Container

  • List running containers.

    vctl ps

  • List all containers, including the running containers and stopped containers.

    vctl ps --all

  • Run a container in detached mode using the nginx image, which is the same as docker.io/library/nginx:latest.

    vctl run --name myContainer -d nginx

  • Run a container using the --publish option and the fluentd image, here fluentd is equivalent to docker.io/library/fluentd:latest.

    vctl run --name myContainer --publish 24224:24224/udp --publish 24224:24224 fluentd

  • Run multiple containers and enable discovery and communication with each other.
    • The vctl utility doesn't have a subnet or a link feature to connect multiple containers to a subnet.

      To enable communication between multiple containers, start the container with the --publish option. This binds the container port to the host port so that the service provided by the container is accessible from the outside.

    vctl run --name mydb -m 2048 -e MYSQL_ROOT_PASSWORD=password -p 3306:3306 mysql

    vctl run --name mymatomo -m 4096 -p 8080:80 -e MATOMO_DATABASE_HOST=<Host_IP>:3306 matomo

  • Run a container using the --volume option and the bonita image, here bonita is equivalent to docker.io/library/bonita:latest.

    vctl run --name myContainer -p 8080:8080 --volume %userprofile%\Documents\container:/opt/bonita bonita

Commands Related to CRX VM

  • Get shell access to a CRX VM.
    • By specifying the container hosted by the CRX VM.

      vctl execvm --sh -c myContainer

    • By specifying the vmx path of the CRX VM.
      Note: To get the vmx path, run the vctl describe myContainer command and refer to the Host virtual machine value in the output.

      vctl execvm --sh %userprofile%\.vctl\.r\vms\myContainer\myContainer.vmx

  • Execute a command within a CRX VM.
    • By specifying the container hosted by the CRX VM.

      vctl execvm -c myContainer /bin/ls

    • By specifying the vmx path of the CRX VM.
      Note: To get the vmx path, run the vctl describe myContainer command and refer to the Host virtual machine value in the output.

      vctl execvm %userprofile%\.vctl\.r\vms\myContainer\myContainer.vmx /bin/ls