Day-41 Basic Docker Commands

Basic Docker Commands

Β·

3 min read

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.

Let's go

Internal Working of Docker πŸ—οΈ

Whatever command you type in the terminal is docker client and it will ask the docker daemon for the output.

Untitled-2022-11-14-2122.png

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.

Untitled-2022-11-14-2122 (1).png

That's how docker internally works.

Docker Basic Commands πŸŽ†

Ok, so now let's do some practical stuff with basic Docker commands.

  • docker version or docker -v : To check Docker version on your system.

Screenshot from 2022-11-28 08-23-14.png

  • docker info: To check complete info about Docker

Screenshot from 2022-11-28 08-25-25.png

  • docker login: To login at docker hub Screenshot from 2022-11-28 08-45-29.png

Screenshot from 2022-11-28 08-27-45.png

  • docker ps: To list out all running containers on the system.

Screenshot from 2022-11-28 08-36-02.png

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.

Screenshot from 2022-11-28 08-45-29.png

  • docker run <container_name>: To create and run specific container.

Screenshot from 2022-11-28 08-52-28.png

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?

Screenshot from 2022-11-28 08-59-41.png

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.

Screenshot from 2022-11-28 09-04-31.png

  • docker pull <image_name>: To pull docker image from docker hub to the local registry.

Screenshot from 2022-11-28 09-17-39.png

  • docker rm <container_id>: To remove specific container

Screenshot from 2022-11-28 09-31-28.png

For removing a Docker container, you have to mention container-id of that container.

  • docker rmi <image_name>: To remove specific docker image.

Screenshot from 2022-11-28 09-37-36.png

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

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 πŸ‘‹

Did you find this article valuable?

Support Shivlal Sharma by becoming a sponsor. Any amount is appreciated!

Β