Skip to content

Latest commit

 

History

History
225 lines (148 loc) · 2.3 KB

docker-docker-compose.md

File metadata and controls

225 lines (148 loc) · 2.3 KB

Docker and Docker Compose commands

Build

  • Build services

    docker-compose build

Containers

  • Startup services

    docker-compose up
  • Startup service

    docker-compose up <service>
  • Run command into service

    docker-compose exec <service> <command>
  • List active containers

    docker container ls

    or

    docker ps
  • List all containers

    docker container ls -a

    or

    docker ps -a
  • Stop active container

    docker container stop <container_name>

    or

    docker stop <container_name>
  • Start container

    docker container start <container_name>

    or

    docker start <container_name>
  • Stop active services

    docker-compose stop
  • Stop active service

    docker-compose stop <service>
  • Remove active services

    docker-compose down
  • Remove container

    docker container rm <container_name>

    or

    docker rm <container_name>
  • Remove container with force

    docker container rm <container_name> -f

    or

    docker rm <container_name> -f
  • Prune containers

    docker container prune
  • Prune containers with force

    docker container prune -f

Images

  • List images

    docker image ls
  • Remove image

    docker image rm <image_id>
  • Remove image with force

    docker image rm <image_id> -f
  • Prune images

    docker image prune
  • Prune images with force

    docker image prune -f

Volumes

  • List volumes

    docker volume ls
  • Remove volume

    docker volume rm <volume_name>
  • Prune volumes

    docker volume prune
  • Prune volumes with force

    docker volume prune -f

Networks

  • List networks

    docker network ls

Actions

  • Execute command into container

    docker exec -it <container_name> <command>

    Example:

    • Enter the container:

      docker exec -it <container_name> bash
  • View container logs

    docker logs <container_name>
  • View container logs with real time

    docker logs <container_name> -f