common info
some commands examples
create volume with arbitrary storage folder
docker volume create --driver local --opt type=none --opt device=/home/mszuyev/test_folder --opt o=bind test_vol
run container with volume mapping
docker run -d -it -v test_vol:/testvol ubuntu:latest
run container with folder mapping
docker run -d -it -v /path/to/folder:/testvol ubuntu:latest
update all existing containers
docker images |grep -v REPOSITORY|awk '{print $1}'|xargs -L1 docker pull
run container
docker container run -it container_name --rm /bin/sh
build container
docker build -t "imagename" .
clean all images (stop container first)
docker rmi -f $(docker images -a -q)
another option to clean only dangling stuff:
docker system prune
Portainer
docker volume create portainer_data
docker run -d -p 9000:9000 -p 8000:8000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
Registry
show auth info (for Gitlab, K8S secret, etc)
echo -n 'user:password' | base64
garbage-collect own registry
Assume <registry-container-name> is a container name with registry:
docker exec -it <registry-container-name> bin/registry garbage-collect /etc/docker/registry/config.yml
List tags with number restriction
curl -u admin:"<admin-password>" 'https://<registry-address>/v2/<maintainer>/<image-name>/tags/list?n=1' | jq '.tags[]'
Tips and tricks
entrypoint for infinitely working container
tail -f /dev/null