/ DevOps

Docker quick cheat sheet

Comments
docker --version
docker --help

# list all images
docker images

# remove image 
docker rmi image-id

# restart a container
docker restart container-id

# remove a container
docker rm container-id

# Remove all exited containers
docker rm $(docker ps -q -f status=exited)

# build a container inside directory with Dockerfile 
docker build .

# list all containers
docker ps -a
# exec bash inside a container
docker exec -it container_name_or_id bash
# display all logs
docker logs --details

# stop only active containers
docker stop $(docker ps -q)
# stop all containers
docker stop $(docker ps -aq)

# list all volumes
docker volume list
# delete a volume
docker volume rm volume-name

# create a docker-compose.yml file then run all containers and update build
docker-compose up --build
# shutdown all containers and remove volumes
docker-compose down -v