Most Basic Docker Commands Every Developer Should Know

In 2020, every developer is expected to know at least some of the Most Basic Docker Commands. Developers should know how to write a dockerfile and must be able to create and deploy images on the local machines. Docker skills remain the same irrespective of the programming language and framework you use.

Learning the basics of docker is really easy and fun. We recommend every backend and frontend developer to spend some time mastering the basics of docker and give their career a boost.

What is Docker?

Docker is a tool designed to make the life of developers and DevOps easier. It easily creates, deploys, and runs applications by using containers.

Docker Containers allow a developer to package up an application with all of the parts it needs, such as libraries, frameworks, and other dependencies, and deploy it as one package.

This package can be saved as a docker image on the Docker hub/repository. By doing so, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that the machine might have that could differ from the machine used for writing and testing the code.


Today we will be listing down some Most Basic Docker Commands.

Most Basic Docker Commands

Docker Images

docker pull

Pull an image or a repository from a registry. This command will pull the image from the docker hub repository.

docker pull {image_name}:{image_tag}

docker pull openjdk

$ docker pull openjdk
Using default tag: latest
latest: Pulling from library/openjdk
bce8f778fef0: Pull complete 
2778faef3420: Pull complete 
945a8b67ac57: Pull complete 
Digest: sha256:7397559527629078208a97b883639be6202c6cd51f287894118f5670745924a9
Status: Downloaded newer image for openjdk:latest


docker images

List all the docker images already pulled from the hub.

docker images

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
wordpress           latest              3065c9654888        20 hours ago        543MB
tomcat              latest              2ae23eb477aa        21 hours ago        647MB
openjdk             latest              0cd6de5fdbee        8 days ago          511MB


docker rmi

The command will remove the image. The image must not be in use by any container.

docker rmi {image_name}:{image_tag}

docker rmi adevguide/AnalysisDash:1.0


docker build

Build/create an image (with given name and tag) from a Dockerfile (from path provided).

docker build -t {imagename}:{image_tag} {path of root of project}

docker build -t AnalysisDash:latest .


docker push

The command will push the image to the docker hub. After the push to the repo, the image will be available for everyone with access. Hub authentication is required before pushing the image.

docker push {repo/image_name}:{image_tag}

docker push adevguide/AnalysisDash:1.0


Docker Containers

docker create

The command will create a new container from the image.

docker create {image_name}

docker create adevguide/AnalysisDash:1.0


docker ps

The command will list all the active/running containers.

The below command will list all the containers.

docker ps -a


Simple Guide To Dockerize Java Application Maven With Dockerfile [2020]


docker run

The command will run/start a new container.

docker run {options} {image_name/id}

The below command will run a container from an image “AnalysisDash” in an interactive mode.

docker run -it adevguide/AnalysisDash:1.0


docker start

The command will start an inactive/stopped container.

docker start {container_id/name}

docker start 6h2t11yf5sc9f


docker stop

The command will stop an active/running container.

docker stop {container_id/name}

docker stop 6h2t11yf5sc9f


docker rm

The command will remove a container.

docker rm {container_id/name}

docker rm 6h2t11yf5sc9f


docker exec

The command will execute a process/command in a running container

docker exec {options} {container_id/name} {command}

docker exec -it 6h2t11yf5sc9f pwd


docker commit

The command will create a new image from the current state of the container.

docker commit {container_id} {image_name}:{tag}

docker commit 6h2t11yf5sc9f adevguide/AnalysisDash:1.0



Docker Documentation


That’s all the Most Basic Docker Commands Every Developer Should Know. Which docker command you use most often? Did we miss any important command? Do let us know in the comments below.