Blog by Yan

Useful Docker Commands

March 28, 2019

Login to container
  • docker exec -it {container_id} /bin/sh
  • docker exec -it {container_id} /bin/bash
Inspect a container
  • docker inspect {container_id}
Delete all containers
  • docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)
Rebuild and Reload a container
  • docker-compose up -d --no-deps --build {container_name}
Delete all unused images
  • docker system prune -a
Delete all volumes
  • docker system prune --volumes
Multiple containers of a single image
  • docker-compose scale service_name=5

Yan Lin Aung

Written by Yan Lin Aung who lives and works in Yangon building useful things. You should follow him on Twitter