Skip to content

Instantly share code, notes, and snippets.

@feeh27
Created August 22, 2019 00:35
Show Gist options
  • Save feeh27/c31633a291891c766b32d22c2f6a4d4c to your computer and use it in GitHub Desktop.
Save feeh27/c31633a291891c766b32d22c2f6a4d4c to your computer and use it in GitHub Desktop.

Docker installation, Docker compose and Docker commands without sudo

Docker installation

Original tutorial: https://withblue.ink/2019/07/13/yes-you-can-run-docker-on-raspbian.html

Install some required packages first

sudo apt update
sudo apt install -y \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg2 \
     software-properties-common

Get the Docker signing key for packages

curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -

Add the Docker official repository

echo "deb [arch=armhf] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
     $(lsb_release -cs) stable" | \
    sudo tee /etc/apt/sources.list.d/docker.list

Install Docker

The aufs package, part of the "recommended" packages, won't install on Buster just yet, because of missing pre-compiled kernel modules. We can work around that issue by using "--no-install-recommends"

sudo apt update
sudo apt install -y --no-install-recommends \
    docker-ce \
    cgroupfs-mount

Enabling Docker at boot

sudo systemctl enable docker
sudo systemctl start docker

Docker compose

Original tutorial: https://withblue.ink/2019/07/13/yes-you-can-run-docker-on-raspbian.html

Install required packages

sudo apt update
sudo apt install -y python python-pip libffi-dev python-backports.ssl-match-hostname

Install Docker Compose from pip

This might take a while

sudo pip install docker-compose

Docker without sudo:

Execute the commands:

sudo mkdir -p /home/"$USER"/.docker
sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
sudo chmod g+rwx "$HOME/.docker" -R
sudo groupadd docker
sudo gpasswd -a $USER docker
sudo usermod -aG docker $USER

Reboot the system

sudo reboot

Test all with hello-world container

docker run hello-world

Cleaning docker (Remove unused Docker Images, Containers, and Volumes)

Original Tutorial : https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes

Remove any stopped containers and all unused images (not just dangling images)

docker system prune -a

Remove all images

docker rmi $(docker images -a -q)

Stop and remove all containers

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

Remove dangling volumes

docker volume prune
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment