Of late I have been exploring on Docker containers. In this post, I have captured most of the commonly used docker commands that one should be aware of while exploring Docker. If you haven’t installed docker yet, follow along the instructions from the official Docker site and install the appropriate version for Mac/Windows.
- To verify the version number of the installations.
docker -v
,docker-compose -v
,docker-machine -v
- To get to know the list of available docker commands
docker help
- To search for available docker images
docker search <searchtext>
- To pull a docker image from docker registry
docker pull <imagename>
- To list the available images in the local machine
docker images
- To run a docker image in a new container
docker run
docker run -d <imagename>
– Run the image in detached modedocker run -it <imagename>
– Run the image in interactive mode, this allows to interact with the image using commandsdocker run --help
– To get to know all the switches available for run command
- To list the running containers
docker ps
- To list all the containers
docker ps -a
- To start a container
docker start <containername>
- To stop a container
docker stop <containername>
- To remove a container
docker rm <containerId>
- To remove an image
docker rmi <imagename>
- To build an image from docker file
docker build -t <tagname> <contextfolder>
– tag name can be any meaningful name; context folder could be the root folder that contains the Dockerfile
- To push an image to remote registry
docker push <imagename>
- To login to the remote registry before pushing the image
docker login -u <username> -p <password>
Though this is not a comprehensive list of commands, I have aimed at putting together the most frequently used commands to get started with. More on other docker commands in a future blog post.
Wow. That is so elegant and logical and clearly explained. Keep it up! I follow up your blog for future post.
Thanks much!