Best practices for building containers

This page lists online resources covering key concepts about how to build containers which are more efficient and secured

Online Resources for Docker best practices

Docker is very popular for developing applications and sharing them faster. Docker has number of commands to achieve tasks.
In this article we will follow some common docker commands that we need everyday. For reference
we are using Docker 19.03.5

Docker arranges the commands in two groups Management Commands and sub commands. This is true for docker 1.13 and later. With this kind of organization it is easy to navigate the commands based on the functional area of docker.






  1. docker - version
  2. docker pull
  3. docker run
  4. docker ps
  5. docker exec
  6. docker stop
  7. docker kill
  8. docker 

Docker Image

To manage docker image these image related commands are used.

List Image (image ls)

To see list of docker images run the following command
docker image ls 

Build Image (image build)

To build an image run the following command 
docker image ls

Save Image (image save)

Save image is used to save an Image not a container. For example to save the docker image bootng-sample to test.tar run the following command
docker image save bootng-sample > test.tar

Tag Image (Image tag)

Docker tag is an alias for an image which is more readable and meaningful than the ID of the image.
To tag an image we can run the following command
docker image tag 0e4d2ffd5f62 "docker_tag_example"

Remove Image

To remove a docker image execute the rm command and specify the id or tag of the image.
For example to remove the image with tag docker_tag_example run the following commad
docker image rm docker_tag_example

Docker Container

Docker container is the running instance of an image. Following commands are commonly used to work with docker containers.


List Containers

It supports many flags like showing all containers, listing only the container ids, filtering containers, showing latest containers etc.
To see containers running or stopped use the following command.
docker container ls

By default it shows only the running containers to see all the containers use the flag --all
docker container ls --all

To list only the container ids use flag --quiet or -q
docker container ls -q

To list only latest container use the flag --latest or -l
docker container ls --latest

Stop Containers

To stop one of more containers use the following command
docker container stop CONTAINERID

Start Containers

To stop one of more containers use the following command
docker container stop CONTAINERID

Rename Container

To rename container use the following command
docker container rename OLD_NAME NEW_NAME

See Logs 

To see logs from the container use the following command

docker container logs CONTAINERID



Docker Community edition for Mac comes with the following different components


Docker Engine
Docker CLI Client
Docker Compose
Docker Machine

Before upgrading checking the versions

$docker -v

 Docker version 17.09.1-ce, build 19e2cf6

$docker-compose --version

 docker-compose version 1.17.1, build 6d101fb

$docker-machine --version
 docker-machine version 0.13.0, build 9ba6da9

If the Docker is running then from the top menu bar click on the Docker icon and navigate to

Check for upgrade