Important docker commands

Here are few very important list of docker commands and its uses which every should know.


docker-machine -v
Displays the docker-machine version.

docker –version
Provides the docker version .

docker -version
Provides the docker version.

docker info
Provides the system full information.

docker images
Provides the list of all images.

docker images -q
Displays the image list only with image id.

docker ps
Gets all the information of running containers

docker ps -a
Gets all the information of running as well as exited containers.

docker –help
Provides help content related to docker commands.

docker login
Helps to login into docker hub

Note :

  • Signup on docker hub and create login credentials.
  • Enter Username and Password on docker terminal screen to get login.
  • If login is successful – you will get message Login Successful.

docker pull
It pulls a image or repository from a registry

docker push
Pushes an image or a repository to a registry

docker build
Builds an image form a Docker file

docker export
Exports a container’s file system as a tar archive

docker exec
Runs a command in a run-time container

docker search
Searches the Docker Hub for images

docker rmi
It removes image or images.

docker rmi -f imagename
Removes the image forcefully.

docker run
It runs a command in a new container.

docker start
Used to start one or more containers.

docker stop
Used to stop one or more containers.

docker stats
Displays the memory usage in the docker.

docker system df
Displays the docker disk usage.

docker system prune
Its removes all stopped containers, networks not used, dangling images, build cache.

docker inspect f
Provides low-level information on docker objects.

docker history imagename:tag
Displays the history of image. Provide the imagename with tag.

docker pause containername/Id
One or more containers processes are paused.

docker unpause containername/Id
One or more containers processes are unpause.

docker top containername/Id
Top process of the container is displayed.

docker stats containername/Id
Stats of the running container is displayed.

docker attach containername/Id
Helps to link to a container.

docker kill containername/Id
Helps to unlink and kill from the container.

docker run -p 8080:8080 imagename:1.0
-p : exposes the port

docker run -d -p 8080:8080 imagename:1.0
-d : run the container in detached mode

docker attach
Attaches to a running container

docker commit
Creates a new image from a container’s changes

docker build –tag imagename:1.0 .
–tag – imagename

Docker Compose

docker-compose -v
Displays the docker compose version.

docker-compose.yml
Create docker compose file at any location on your system.

docker-compose config
compose the docker-compose yml file

docker-compose up
Run the docker-compose.yml file.

docker-compose up -d
Ups the containers in detached mode

docker-compose down
Downs all the container

docker-compose up -d –scale servicename=4
It will create 4 instances of provided servicename

docker-compose down –rmi all
Stops all containers, removes all container, removes all images

docker-compose start
Start all the containers.

docker-compose stop
Stops all the containers.

docker volume
Manage the volumes.

docker volume create
Create a volume.

docker volume ls
List the volumes.

docker volume inspect
Display detailed information on one or more volumes.

docker volume rm
Remove one or more volumes.

docker volume prune
Remove all unused local volumes.


Check Similar Blogs :

Download / Install Docker Toolbox ( Windows 7 & Above )
Download / Install Docker Toolbox ( macOS )
Download / Install Docker Desktop ( macOS)
Download / Install Docker ( Ubuntu )
Download / Install Docker ( CentOS )

Hope this information was helpful to you.
Feel free to comment if you face any issues or have any doubts.

Leave Your Reply

Your email address will not be published. Required fields are marked *