Introduction
Welcome 👋 to this blog. If you want to learn about Docker and are a beginner, you have come to the right place. This blog series will cover everything from the very beginning to the end. This blog will teach us about the necessary and important Docker commands.
List of commands
List the containers that are actively running
$ docker ps
Note: If the Docker commands are not running in your system, it is not installed or does not have enough privileges to use it with sudo
commands.
List all the containers irrespective of their running status
$ docker ps -all
Run a Docker container
Step 1: Create a container
$ docker container create hello-world:linux
Here, hello-world:linux is a hello world container image which is pulled from the docker hub
Step 2: Start the container
$ docker container start <Container ID>
Here, is the container ID which can be obtained by running the previous commands docker ps
.
Running the Docker container(short way)
$ docker run hello-world:linux
docker run = docker container create + docker container start + docker container attach
Getting the log of the container
$ docker log <Container ID>
Run additional commands from the container
$ docker exec <Conatiner ID> <Commands>
Starting a interactive shell
$ docker exec --interactive --tty <Container ID>
Stop the container immediately
$ docker stop -t <ID>
Remove the container
$ docker rm <Container ID>
List all the docker image
$ docker images
Remove the Docker image
$ docker rmi <Image ID>
Remove the Docker Image forcefully
$ docker rmi -f <Image ID>
Binding ports to the container
$ docker run -p 5001:5000 our-server
Tagging the image name
$ docker tag <Local-image-name> username/your-image-name:0.0.01
Conclusion
In this blog, we explored different commands of Docker containers, images, emphasising their roles in container & image creation. In the next blog, we will delve deeper into the technical aspects. Stay tuned
Hire me: [email protected]
LinkedIn
Twitter