15 Docker Commands Beginners Should Know

In this post, basically, I don’t put options. If you think this command is lacking something important, you will need to check Docker Doc(https://docs.docker.com/)

pull

pull command is almost same as git pull. Get an image to local from Docker hub.

push

push command is also the same as git push. This command uploads your Docker image to Docker Hub. This allows others to use your image or you can use the image from any machines. For example, you can use the image for CI. I’m using my own image for Circle CI to run the test.
The free plan allows us to have one private repo. You can make your image secure. The following: python3.7 is a tag. Generally, a community organization provides multiple versions of images.

For example, node:latest, node:11, node:10 etc.

build

This command is to create an image from Dockerfile. You can see what Docker file is in the following post.
https://dev.to/kojikanao/learning-docker-002-images-5deb

ml_conda_docker is an image name & tag.

images

This command shows you images you have. I think I have used this command so many times lol

rmi

This command is to remove an images. Sometimes images are huge, so need to delete images especially when I create an image from container which is based on an image from Docker Hub.

create

This command creates a container but doesn’t start a container.

run

This command is to run a container or start a container.
You should check the options.
https://docs.docker.com/engine/reference/run/
Also you can check my post about container(https://dev.to/kojikanao/learning-docker-001-containers-5ac6)

ps

ps could be your best friend when you use Docker.
This command shows you running containers’ information. If you want to see stopped containers, you can add -a.

commit

This command allows us to create an image from a container. We can pull an image and add/install anything we need then do commit. After that, we can start run/create a container the image we committed.
One thing you should know is that commit creates a new image from the image you pulled and the size of the new one could be bigger than the based one. So, you need care about your storage if you don’t have enough storage on your machine.

start

This command is to start running a container.

stop

This command is to stop a running container.

exit

When you are in Docker container, you can use exit to get out there.

attach

This command to attach local standard input, output, and error streams to a running container.

rm

This command deletes a container which is not running. You can remove multiple containers if you put multiple container_ids

system prune

This command is to remove unused data.
If you really want to clean up your Docker environment, you can use -aoption. However, this option removes all unused data so be careful when you use this option.

exec

This command allows us to exec another process in a running container.

Actually, there are so many commands you can use/should know, but I guess for a beginner like me these commands are kind of enough to learn the basics of Docker.

Hope this is useful for someone!

If something wrong or missing something important, please leave a comment!!!(I’m still learning Docker 😆)

Docker Doc
https://docs.docker.com/

Docker cheat sheet
https://github.com/wsargent/docker-cheat-sheet

If you don’t like to use CLI, you can use Docker with GUI like kitematic(https://kitematic.com/), but probably CLI could be helpful to understand Docker since we will need to write Dockerfile, docker-compose.yml.

Credit @Dev.to

TranIt.Co Comments - Leave your comment or ask a question
Tags: