Docker Commands Beginners Should Know

Docker Commands Beginners Should Know

Are you new to docker and confused by the multitude of commands?

Before we get into the features and functionality of Docker, it is important to understand why Docker is necessary.

This meme is about Docker’s introduction if you have been in this industry for a while. This meme may be funny, but it is actually quite factual.

The Life Before Docker

Prior to the introduction Docker shipping applications to intended users was not only a complicatedtask, but also tedious. Artifacts such as zip files, wheel or JAR files were sent to the user and then installed on their computers. You will now wonder if this way of shipping and deploying apps was successful.

The after-effects of deploying the applications are the key to the answer. After an application or other software has been installed on a user’s computer, it might not function as expected. The two main reasons that the applications don’t work on all machines are:

  1. Applications version discrepancy between different machines
  2. Inconsistent environment variables across machines

Docker solved both these problems by packaging the software so that all versions are stored in a file called Dockerfile.


Dockerfile contains all information about software dependencies. The Dockerfile executable is run on the user’s system. With the help of the commands in the Dockerfile, the software is installed.

The Dockerfile is usually the only thing that gets shipped to the user





print('Hello All')

To help you understand the concept, here is a Dockerfile sample.


FROM ubuntu.latest


COPY /loc


RUN make/loc


CMD python. /loc/

Let’s see how this Dockerfile works.

1. FROM Ubuntu:latest : This creates an layer in the ubuntu Operating System on which all the commands from Dockerfile can run. Once this line has been executed, the Ubuntu OS can be downloaded from the .

2. COPY. /loc: This copies all files from the current directory into the /loc directory.

3. RUN make: After we have installed Ubuntu OS, we can use make to compile files in /loc directory.

4. CMD Python /loc/ : The CMD Command executes the python program on the user’s computer.

This Dockerfile is not intended to be used in a software release.

How to Run a Dockerfile

After the Dockerfile has been sent to the user, it should be executed with some special commands. Let’s see how to execute a Dockerfile.

Dockerfile construction

docker-build -t Mudit111/docker

build is used to create a Dockerimage from a Dockerfile. The syntax of this command is t to the name your newly created Dockerimage. The is used to tell the compiler that the Dockerfile exists only in the current directory.

You will not be able to find the Docker file if you attempt to search the directory. The Docker image is not stored in a single file. The system handles the storage of a Docker Image. What if you have to view images stored in the system at a particular time? In the next section, we will discuss this.

The Docker images are listed

Docker image

You can quickly list all Docker images in your system by using the command above. These details would be included in the listing of Docker images:

  • TAG
  • SIZE

These Docker images are also available for sharing to the Docker Hub so that other users can download your project quickly. Docker Hub works in the same way as GitHub. Docker Hub stores Docker files, just like GitHub does.

Docker Image

docker run mudit111/docker

You will see the output of the Docker Docker Image

A docker container is automatically created when a Docker image has been run. The Docker container remains in an active state until completion of the Docker images. The Docker container will stop automatically when the Docker image has been completed.

List of Docker Containers


This command allows you to view running containers. This command will only list containers that are in a running status. This command will show containers that have been created but are currently stopped. To list all containers (including those that are not currently in running state), you will need to add –all to the end of the current command.

The docker PHP0_ command won’t show anything because our container is not currently running. However, if you add -all to the command, it will display all stopped and running containers .

Pushing a Docker image to Docker Hub

push mudit111/docker

After the Docker image is created, you can publish it to Docker Hub with docker pull command. Users around the world can access the Docker image via Docker Hub by pushing it to Docker Hub.

You must have a Docker Hub account before you can push your Docker images to Docker Hub.

You can also pull any Docker image public from Docker Hub

A Docker Image from Docker Hub

docker pull muit111/docker

You can download any Docker image to your system by using the DOCKER pull command. After the Docker image has been downloaded to your system you can use doncker run in order to run it.

After you’re done with the commands, you can create a Dockerfile and upload it into Docker Hub. Then, you can ask anyone to download the Docker image from Docker Hub, and then try to run it.

Leave a Reply

Your email address will not be published.