Understand docker run command in 1 minute

0
666
docker

This blog post is part of the 1-minute read. If you are the beginner of the docker and just started installing the docker on Linux or Mac. You must be wondering what to do after this?

If your installation of the docker is successful then you can just run the simple nginx container with the following command.

$ docker run -p 8080:80 nginx:latest

Here docker is the command-line utility. The option -p is responsible for binding the host post with container port. Here host port 8080 is mapped with the 80 port. To run the nginx we are proving the image-name:tag-name. The image with tag is the standard way of representing the docker image. By default, docker daemon will fetch the image from the public repository that is docker hub.

$ docker run -d -p 8080:80 nginx:latest

The only difference here is -d option. If you don’t use -d option the docker container process will run in the foreground. But if you use the -d option then it will be a background process.

You can check running processes with following command,

$ docker ps 
Docker ps command output

The output in the browser:

Nginx running with docker container
Nginx running with docker container

If you liked the blog please share and don’t forget to look some other interesting blogs like Understanding Kubernetes Pod.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments