Frequently used commands in Docker

Maciej
1 min readAug 6, 2020

--

For anyone new to Docker, this is a good guide. Take a look at this list of Docker commands and see how you can use them.

Check the container status

docker ps

Check container size

docker ps -s

Confirm including already finished containers

docker ps -a

Create Docker image

docker build -t (container name): (version) (Dockerfile location)

Build a container managed by docker-compose

docker-compose build

Run a container managed by docker-compose in the background

docker-compose up -d

Terminate the container managed by docker-compose and delete the container

docker-compose down

Terminate the container managed by docker-compose

docker-compose stop

Access inside docker container

docker exec -it (container ID/container name) (bash/sh)

Delete unused Network

docker network prune

Delete unused Volumes

docker volume prune

Delete unused Container

docker container prune

Batch deletion of unused systems

docker system prune

Delete a container that has already ended

docker rm (container ID/container name)

Forcibly delete all, including running containers

docker rm -f `docker ps -aq`

--

--

Maciej
Maciej

Written by Maciej

DevOps Consultant. I’m strongly focused on automation, security, and reliability.

No responses yet