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
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
You will see something like this if you successfully ran the command.
Few more basic commands you need to know.
version
command used to check the version of the docker.
$ docker version
info
command gives you current status like the number of the running containers, paused, stopped, and all other things.
$ docker info
ps
command will specifically tell you the information about running containers like container id, name, port, status, etc.
$ docker ps
-all
flag will show you information about all containers.
$ docker ps -all
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>
stop
command will stop the running container as soon as a container finished its process.
$ docker stop <process>
kill
command will stop the container immediately, no matter if it finished its process or not.
$ docker kill <process>
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.
Top comments (0)