Some useful commonly used docker commands when working on OSX with VirtualBox.

1) This ensures the boot2docker VM is up and running.

docker-machine start default

2) This is the command that needs to be executed once for every new terminal window opened, so as to establish connection with the boot2docker vm.

 eval “$(docker-machine env defaut)”

3) This command returns the IP address of the ‘default’ VM running boot2docker

docker-machine ip default

4) Returns a list of VM with boot2docker install and running on VirtualBox.

docker-machine ls

Sample Output:

NAME        ACTIVE   DRIVER       STATE     URL                         SWARM   ERRORS
default     *        virtualbox   Running   tcp://           

5) Regenerates the TLS certificates needed to communicated with the ‘boot2docker’ VM.

docker-machine regenerate-certs default     /// To regenerate the TLS certs for docker

6) Lists all available docker images

 docker images

7) Looks the docker process running with a particular container id.

docker ps -a | grep <container -id >

8) Removes a running docker container

docker rm <container id>

9) Removes a particular docker image

docker rmi  <imageid>

10) Kills a particular docker container

docker kill <container-id>

11) Connects to the docker container and gives access to the bash shell to execute commands on the container

docker exec -i -t <container id> /bin/bash

12) Runs a docker image and does not automatically terminate the container. Allows an easy way to keep the container running and later connect to the containers shell using “docker exec -it “ command.

docker run -d <image-name> tail -f /dev/null

13) This is not a docker command. This utility is part of the virtual box installation. Allows one to power-off a VM running on VirtualBox

VBoxManage controlvm <vm-name> poweroff

14) Again, not a docker command. A virtual box command to share a directory on the HOST OS (OSX: /Users/esrinivasan/..) with the guest operating system running on VirtualBox. The name of the shared folder is set as “/eks” here.

VBoxManage sharedfolder add default --name /eks --hostpath /Users/esrinivasan/develop/learning/Docker/dec-2016/docker-node/docker-volume

Elankumaran Srinivasan

Elankumaran Srinivasan
I am a software engineer, Java and open source technonogy enthusiast.

Counter-Badging Service Architecture

Most of the applications have some sort of badging functionality which is used to display certain counts to the users for CTA (Call To Ac...… Continue reading

Hystrix, Turbine with Spring Boot Admin

Published on April 16, 2017

Implementing CHAT system with MongoDB Atlas

Published on February 27, 2017