Skip to main content

Docker compose

	•	docker-compose up
Creates and starts containers as defined in the docker-compose.yml file.
• docker-compose up -d
Starts containers in detached mode.
• docker-compose down
Stops and removes containers, networks, images, and volumes created by up.
• docker-compose down --volumes
Stops services and removes containers along with their volumes.
• docker-compose build
Builds (or rebuilds) the images for services defined in the compose file.
• docker-compose build --no-cache
Builds images without using any cached layers.
• docker-compose logs
Displays logs for all services managed by Docker Compose.
• docker-compose logs -f
Follows (tails) logs for all services in real time.
• docker-compose ps
Lists containers created by Docker Compose.
• docker-compose restart
Restarts all running services.

Docker

	•	docker build -t <image_name> .
Builds a Docker image from a Dockerfile in the current directory.
• docker run -d -p <host_port>:<container_port> --name <container_name> <image_name>
Runs a container in detached mode, mapping host port to container port.
• docker ps
Lists currently running containers.
• docker ps -a
Lists all containers, including those that are stopped.
• docker stop <container_name>
Stops a running container.
• docker start <container_name>
Starts a stopped container.
• docker restart <container_name>
Restarts a container.
• docker logs <container_name>
Displays the logs of a container.
• docker exec -it <container_name> bash
Opens an interactive Bash shell inside a running container.
• docker rm <container_name>
Removes a container.
• docker rmi <image_name>
Removes a Docker image.
• docker system prune
Cleans up unused containers, networks, images, and optionally volumes.
• docker inspect <container_or_image>
Displays detailed low-level information on a container or image.