The famous global researcher Gartner predicts that by 2023, more than 50 percent of companies will be adopting Docker containers in production. However, a serverless container like Docker will have the revenue from a small base of $465.8 million in 2020, to reach $944 million in 2024.
That was all about the demand for Docker in the market.
In this tutorial, we will be discussing the Top Docker Commands that a developer uses frequently while working with the Docker tool.
What Is Docker?
Docker is a configuration management tool that helps a developer to wrap an application and its dependencies into a Docker Container for the development and deployment of software.
Moving forward, let’s discuss the top Docker commands that are widely used by the developers.
List of Docker Commands
- Build an image from the Dockerfile in the current directory and tag the image
docker build -t myimage:1.0 |
List all Docker images
docker images |
Delete an image from the docker image
docker image rm alpine:3.4 |
Container Commands
Mentioned below are the necessary commands for working with Docker container images.
- Create a container
docker create [IMAGE] |
- Run a command in a new container
docker run [IMAGE] [COMMAND] |
- Rename an existing container
docker rename [CONTAINER_NAME] [NEW_CONTAINER_NAME] |
- Removes all the stopped containers
docker container prune [OPTIONS] |
- Create a new image from a container’s file changes
docker container commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] |
- Remove an existing container
docker rm [CONTAINER] |
- List the running containers
docker container ls |
- Stop a running container
docker stop [CONTAINER_NAME] |
- Restart a running container
docker restart [CONTAINER] |
- Kill the running containers
docker Kill [CONTAINER] |
- Attach local standard input, output, and error streams to a running container
docker attach [CONTAINER] |
- Block a container
docker wait [CONTAINER] |
Docker Share Command
The following commands show how to share command in Docker.
- Pull an image from a registry
docker pull [OPTIONS] NAME[:TAG] |
- Push an image to a registry
docker push [OPTIONS] NAME[:TAG] |
- Run a command in a running container
docker exec [OPTIONS] CONTAINER COMMAND [ARG...] |
General Commands
The following code shows the general command in Docker.
- Login into docker hub
docker login |
- Get information on the Docker tool
docker info |
- Display the history of an image with the image name mentioned in the command
docker history httpd |
- Create a volume for containers
docker volume create |
Docker Swarm Commands
Below you will find all the frequently used Docker Swarm commands.
- Create a Docker Swarm
docker swarm init --advertise-addr [IP ADDRESS] |
- Joins nodes in the swarm
docker swarm join --advertise-addr HOST:PORT |
- Execute this command to leave docker swarm
docker swarm leave [OPTIONS] |
Docker Compose Commands
Below you will find all the frequently used Docker Compose commands.
- Display docker-compose version
docker-compose -version |
- Creating your first Docker-Compose File
vi docker-compose.yml |
- Run our Docker Compose file
docker-compose up |
Enroll for the Docker Certified Associate Training Course to learn the core Docker technologies like the Docker Containers, Docker Compose, and more.
Conclusion
That was all the basics about Docker Commands.
If you are interested in gaining in-depth knowledge of the Docker tool, Simplilearn can definitely help you. The Docker In-Depth Training Course will help you learn all the basic and advanced concepts of Docker. With this certification, you will gain hands-on experience on how to create flexible application environments with Docker.
Do you have any doubts about this topic? Please feel free to place your questions in the comments section of this Docker Commands tutorial and our experts will get back to you at the earliest!