Cheat Sheet - Docker

Cheat Sheet - Docker

Installation

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

Add your user to the Docker group:

sudo usermod -aG docker $USER

Activate changes:

newgrp docker
Build full logs
docker build --progress=plain --no-cache ..

Docker Registry

To list private Docker registry images you can open the following link: https://registry.example.com/v2/_catalog

Install Docker Compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Autocompletion for docker-compose:

sudo curl -L https://raw.githubusercontent.com/docker/compose/1.26.2/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose

Remove all images

docker rmi $(docker images -q) -f

Remove unused images

docker images -q |xargs docker rmi

Stop all containers

docker stop $(docker ps -aq)

Remove all containers

docker rm $(docker ps -aq)

System cleanup

docker system prune -a -f

Copy the file from the container

If you need to copy a file from a running container you can use the docker cp command:

docker cp container_name:/path/to/file /dest/to/file