Docker : A quick reference commands
Docker is a containerization system which packages and runs the application with its dependencies inside a container. In this post, I will share with you 10 Docker Commands you need to know while working with Docker:
- docker –version One of the first things we all want to know is how to find the installed docker version
- docker pull <image name> The ‘docker pull’ is a Docker command to download a Docker image or a repository locally on the host from a public or private registry.
- docker images List all the docker images pulled on the system with image details such as TAG/IMAGE ID/SIZE etc
- docker run <image name> The docker run command creates a container from a given image and starts the container using a given command. It is one of the first commands you should know. If the image is not present locally, docker first pulls the image and runs it
- docker ps docker ps command lists all the docker containers that are running with container details. To list all the docker containers running/exited/stopped with container details, we use docker
ps -a
command - docker start/ stop/restart docker start command in docker starts the docker container with container id mentioned in the command. docker stop stops a container with container id mentioned in the command. To restart the docker container, we use docker restart
- docker rm Remove the docker container with container id mentioned in the command.
- docker rmi Remove the docker image with the docker image id mentioned in the command
- docker info Get detailed information about docker installed on the system including the kernel version, number of containers and images, etc.
- docker search Search for a docker image on dockerhub with the name mentioned in the command.
- docker system df Check disk space being used by your containers
- docker cp container-name:/file/path /host/path Copy file from container to host
- docker cp /host/file/path container-name:/path/ Copy file from host to container
- docker volume rm volume-name Remove a Docker volume
- docker network rm network-name Remove a Docker network
- docker container run -it image-name /bin/bash Run a container in interactive mode
- docker container rename oldname newname Rename a container
- docker inspect -f “{{ .NetworkSettings.IPAddress }}” container-name Check the IP of a container
- docker ps -qa List all container by their ID
- docker exec -it container-name /bin/bash SSH into a container
Enjoy