DEV Community

Cover image for Pulling the first Docker image and a few essential commands.
Uddesh
Uddesh

Posted on

Pulling the first Docker image and a few essential commands.

Today we will pull our first docker image and take a look at a few essential docker commands you need to know to get moving in this journey of docker.

Before we start, you should check out the previous post of this series if you are not familiar with docker, and it's the installation process.

Hello World is our favorite message when it comes to getting started with something. Isn't it?

So today, we will pull Hello World docker image from Docker Hub and run it. But first things first, What Docker Hub is?

Well, Docker Hub is a collection of Docker images either created by organizations (ex: nodejs, MongoDB, oracle) or by individual developers. Images on Docker Hub are ready to use images. Someone already configured them for you. You need to pull or download them to use.

Pull Command

Pull command downloads the docker image from the docker hub. That's it.

$ docker pull hello-world
Enter fullscreen mode Exit fullscreen mode

Run Command

Run command used to run docker images that are pulled from the docker hub or build on the local machine. One more thing Run command first looks for images to run locally, and if it doesn't find the image, it will automatically pulls the image for you. So in case you are a bit lazy to pull and run an image. Just type the run command, and it will help you.

$ docker run hello-world
Enter fullscreen mode Exit fullscreen mode

You will see something like this if you successfully ran the command.

Alt Text

Few more basic commands you need to know.

version command used to check the version of the docker.

$ docker version
Enter fullscreen mode Exit fullscreen mode

info command gives you current status like the number of the running containers, paused, stopped, and all other things.

$ docker info
Enter fullscreen mode Exit fullscreen mode

ps command will specifically tell you the information about running containers like container id, name, port, status, etc.

$ docker ps
Enter fullscreen mode Exit fullscreen mode

-all flag will show you information about all containers.

$ docker ps -all
Enter fullscreen mode Exit fullscreen mode

start command will start previously ran container again. Don't confuse between run and start. Run command used to run a new container.

$ docker start <process>
Enter fullscreen mode Exit fullscreen mode

stop command will stop the running container as soon as a container finished its process.

$ docker stop <process>
Enter fullscreen mode Exit fullscreen mode

kill command will stop the container immediately, no matter if it finished its process or not.

$ docker kill <process>
Enter fullscreen mode Exit fullscreen mode

Now docker has a whole lot of commands that we will learn in the future, but I think these are the essential ones. I hope this will help you. I will back with other things about docker until then, Bye.

bye

Top comments (0)