#
# Docker
#
docker start <container_name> # start particular container
docker start -i <container_name> # start particular container in interactive mode
docker stop <container_name> # stop particular container
docker ps # display all running containers
docker ps -a # display all existing containers (stopped)
docker exec -it <container_name> /bin/bash # join to the container via bash
docker rm <container_name> # remove particular container
docker rmi <image_name> # remove particular image
docker pull <image_name> # download particular image from the remote repository (NC Artifactory, dockerhub, etc)
# Display on-line information regarding system usage (CPU,RAM,IO) per container
docker stats $(docker ps | awk '{if(NR>1) print $NF}')
# Remove all images by pattern
docker images | grep <part_of_image_name> | awk '{print $1}' | xargs docker rmi
# Remove unused images
$ sudo docker images
$ sudo docker rmi $(sudo docker images --filter "dangling=true" -q --no-trunc)
# Remove all containers by image
docker ps -a | awk '{ print $1,$2 }' | grep <image_name> | awk '{print $1 }' | xargs -I {} docker rm --force {}
# Remove all containers
docker rm $(docker ps -a -q) --force
# Remove volumes
$ sudo docker volume rm $(sudo docker volume ls -qf dangling=true)
$ sudo docker volume ls -qf dangling=true | xargs -r sudo docker volume rm
# Remove networks
$ sudo docker network ls
$ sudo docker network ls | grep "bridge"
$ sudo docker network rm $(sudo docker network ls | grep "bridge" | awk '/ / { print $1 }')
#
# Docker-compose
#
# Create a new environment based on <compose.yml> file. Output will be redirected to terminal.
docker-compose -f <compose.yml> up
# Create a new environment based on <compose.yml> file. Container will start in background.
docker-compose -f <compose.yml> up -d
# Stop/remove/create and start particular container (volumes won't be affected)
docker-compose -f <compose.yml> rm --force -s <service_name> && docker-compose -f <compose.yml> up -d
Last active
April 18, 2019 10:01
-
-
Save dgroup/5046bac5531fae11242dd03201626f5b to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment