Examples of vctl Commands
The command-line examples that follow work on VMware Fusion.
Commands Related to Image
- When you build a new image, to pull the base image from a private Docker registry successfully, either use thevctl logincommand to log in to the private Docker registry first or use the--credentialoption to pass a JSON file that stores credentials tovctl buildcommand for registry authentication. For example:
- Encode your Docker registry username and password in base64 with the following command:echo -n USER:PASSWORD | base64
- Create aconfig.jsonfile with your Docker registry URL and the base64 encoded string generated in step 1.{ "auths": { "https://index.docker.io/v2/": { "auth": "xxxxxxxxxxxxxxx" } } }
- Build the new image whose base image is in a private Docker registry, by passing the JSON file tovctl buildcommand: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 thenginximage, which is the same asdocker.io/library/nginx:latest.vctl run --name myContainer -d nginx
- Run a container using the--publishoption and thefluentdimage, herefluentdis equivalent todocker.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--publishoption. 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 mysqlvctl run --name mymatomo -m 4096 -p 8080:80 -e MATOMO_DATABASE_HOST=<Host_IP>:3306 matomo - Run a container using the--volumeoption and thebonitaimage, herebonitais equivalent todocker.io/library/bonita:latest.vctl run --name myContainer -p 8080:8080 --volume ~/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.To get the vmx path, run thevctl describe myContainercommand and refer to theHost virtual machinevalue in the output.vctl execvm --sh <Home_Folder_of_Your_Account>/.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.To get the vmx path, run thevctl describe myContainercommand and refer to theHost virtual machinevalue in the output.vctl execvm <Home_Folder_of_Your_Account>/.vctl/.r/vms/myContainer/myContainer.vmx /bin/ls