Okay, so last time we discussed Docker containers and Docker images and the differences between both. Today we are going to look at the internal workings of Docker and some basic Docker commands.
Internal Working of Docker ποΈ
Whatever command you type in the terminal is docker client and it will ask the docker daemon for the output.
Suppose you are running a command to run a specific image in Docker, then the first Docker client will ask the Docker daemon to check whether it is available in local image registry or not. Otherwise, it will pull that image from Docker hub and run that image and its container.
That's how docker internally works.
Docker Basic Commands π
Ok, so now let's do some practical stuff with basic Docker commands.
docker version
ordocker -v
: To check Docker version on your system.
docker info
: To check complete info about Docker
docker login
: To login at docker hub
docker ps
: To list out all running containers on the system.
Currently, there are no containers running on my machine, so it is not showing anything. But you can use docker ps -all
to list all running and stopped containers.
docker run <container_name>
: To create and run specific container.
Here, we are running a Hello-World container. Because the Hello-World container image is already in the local registry, it did not search for Docker Hub. But what if we create a container whose image is not present in the local registry?
Here, ubuntu
was not present in the local registry so it pulled the latest image from docker hub and run it.
docker images
: To list all docker images in your system.
docker pull <image_name>
: To pull docker image from docker hub to the local registry.
docker rm <container_id>
: To remove specific container
For removing a Docker container, you have to mention container-id of that container.
docker rmi <image_name>
: To remove specific docker image.
For removing a Docker image, you first have to remove all running or stopped containers from that image.
docker start/stop <container_name>
: To start or stop specific container.
Resources π
So those were all the basic Docker commands that you should know. You can refer to the above resources to understand it better. And that brings our blog to a close; see you in the next one π