docker cheat sheet - beginners guide

Docker Useful Hacks: Cheat Sheet For Beginners to Experts

Docker has many commands to remember. If you are starting up with docker, We are pretty sure that you will have a hard time remembering all those commands and to manage containers. In this article, we have explained the necessary command to make you more productive while working with docker.

Docker Useful Hacks

The following section contains useful hacks that help you while working with docker. We don’t recommend using the bulk stopping and removing commands in production. This is just for dev purposes.

Run docker without sudo

When you install docker, you have to use sudo to work with docker commands. To avoid using sudo, you need to add your current user to docker group using the following command. Restart the terminal for the changes to take place

Execute the following command if you do not want to restart the terminal

Connecting to Docker Container

Use “docker exec” command to connect to a running container. This command will attach a shell session in your current terminal.

Remove Unused Docker Objects

The best way to remove all stopped, dangling and unused networks is through prune command.

You can remove all unused docker volumes using volume prune command.

Stopping all containers at once

To forcefully stop,

Removing all containers at once

To forcefully remove,

Removing all docker images at once

To forcefully remove,

Assign a name to the container

To assign a name to a container, use the “–name” parameter as shown below.

List all running containers

To list all the running containers, you can use the docker ps command

List all containers

To list all running, stopped and exited containers, you can use the -a flag.

List all images

To list all the available docker images in your host, use the following command.

Remove unwanted/intermediate/untagged images

Most of the times while building new images, there is a possibility of untagged, intermediate images that might eat up your disk space as well as increases your images list. To clean up those images, you can use the following command.


There are few situations in which you might want to get into the container shell or may be run a single command in a…

Read more
docker remote api

You will need Docker remote API in various situations. Let's say you are running the docker host on a remote server…

Read more

The Best Tutorials & Tips to Speedup Your DevOps Workflow.

Created by Bibin Wilson.