Docker Commands

Sumeet Gyanchandani
Analytics Vidhya
Published in
2 min readJul 12, 2020
Source: https://www.docker.com/company/newsroom/media-resources

You can download and install Docker Community Edition for free. You can follow the instructions on Docker’s website, they are pretty straight forward and always latest.

  1. Introduction
  2. Docker File
  3. Basic Docker Commands ( You are here! )
  4. Port and Volume Mapping
  5. Docker Networking
  6. Docker Storage
  7. Docker Compose
  8. Deleting Docker Entities

Apart from the commands described below, I would like to refer you to a cheatsheet released by docker. They are now streamlining their commands, hence you’ll find several commands to do the exact same thing, for instance, removing an image can be done by either docker rmi or docker image rm command.

pull command

This command pulls an image from a docker public registry.

docker pull docker/whalesay

build command

This command builds an image according to Dockerfile.

docker build [-t <name_of_image>] [-f <name_of_Dockerfile>] <path_to_Dockerfile>

run command

This command runs an instance of an image.

docker run --name nginx-container nginx:1.16

ps command

This command lists the docker containers.

docker ps

stop command

This command stops a running container(s).

docker stop nginx-container

rm command

This command removes a stopped container(s).

docker rm nginx-container

images command

This command lists the docker images.

docker images

rmi command

This command removes image(s).

docker rmi nginx

attach command

This command attaches the terminal to a container running in the background (detached mode).

docker attach <container id or name>

inspect command

This command returns details of the container in a JSON format.

docker inspect <container id or name>

logs command

This command returns logs of the container running in the background (detached mode).

docker logs <container id or name>

push command

This command pushes an image to your account on a docker public registry (dockerhub).

docker push sumeet/mlflow-postgres

In the next section, we will learn about port and volume mapping.

--

--

Sumeet Gyanchandani
Analytics Vidhya

Associate Director at UBS | Former Machine Learning Engineer at Apple, Microsoft Research, Nomoko, Credit Suisse | Master of Science in Artificial Intelligence