Skip to content

Docker Commands Reference

docker show running containers:

Show running containers.

docker ps

docker show all containers:

Show all containers (running and stopped).

docker ps -a

connect inside container

Launch an interactive shell inside a container.

docker exec -it <CONTAINER-ID> bash

Stop a container

Stop a container.

docker stop <CONTAINER-ID>

Start a container

Start a container.

docker start <CONTAINER-ID>

Remove a container

Remove a container.

docker rm <CONTAINER-ID>

docker images list

List locally downloaded images.

docker images

Remove an image

Remove an image.

docker rmi my-custom-image

Docker networks list

Docker networks list.

docker network ls

Docker volumes list

Docker volumes for data storage list.

docker volume ls

docker detailed information

View detailed information about a container, image, or network configuration.

docker inspect CONTAINER ID

docker pull

Download an image from Docker Hub or another image registry. (Nginx in this case)

docker pull nginx

docker build:

Build an image from a Dockerfile in the current directory.

docker build -t my-custom-image .

docker run:

Run a container based on an image.

docker run -d -p 8080:80 --name my-web-app nginx

docker-compose start your config .yml

Manage multi-container applications using a docker-compose.yml file.

docker-compose up -d

docker-compose start to build containers

Build or rebuild services defined in a docker-compose.yml file.

docker-compose build

docker-compose Stop and remove all containers

Stop and remove all containers, networks, and volumes created with docker-compose up.

docker-compose down

docker-compose logs:

View logs from a multi-container application started with docker-compose.

docker-compose logs

By default, docker-compose logs displays all logs in real-time. However, you can also use options to customize the output:

-f or --follow: Follow log changes in real-time (similar to docker logs -f). --tail="all": Display the last N lines of the log (default is "all" - all lines). --timestamps: Show timestamps in the logs.

docker-compose logs -f --tail="50" --timestamps

docker-compose ps

View the status and information of containers in a multi-container application.

docker-compose ps

docker system removing all unused data

Clean up the Docker system by removing all unused data, including images.

docker system prune -a