Install Docker
Docker can be installed as described in the installation notes on docker.com.
Set up the repository
update apt package index and install prerequisites
sudo apt-get update
sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common
Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
Add stable arm64 repository for debian10
sudo add-apt-repository \ "deb [arch=arm64] https://download.docker.com/linux/debian \ $(lsb_release -cs) \ stable"
The docker daemon uses iptables for NAT while Debian uses nftables. Switching to iptables-legacy prevents dockerd from being unable to start
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
Install Docker engine
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
Done - installation can be verified by running the hello world docker container:
sudo docker run hello-world
Get Docker Compose
Docker Compose allows the user to easily configure more complex docker projects containing multiple images in multiple containers with dependencies and network links set up.
Unfortunately there is no prebuilt arm64 version of Docker Compose available. The easiest way to run Docker Compose anyway is to run it in a Docker container as described here.
The docker container can be used almost like a native installation of Docker Compose after running the following two commands:
sudo curl -L --fail https://raw.githubusercontent.com/linuxserver/docker-docker-compose/master/run.sh -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
With this setup docker-compose.yml-files can simply be started with the docker-compose up -d
command.
Docker Compose example
This is the contents of a working docker-compose.yml file that sets up a wordpress webserver that depends on a mariadb database.
version: '2' services: db: image: mariadb volumes: - ./data/db/:/var/lib/mysql restart: always ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: wproot MYSQL_DATABASE: wordpress MYSQL_USER: wpuser MYSQL_PASSWORD: wppass wordpress: depends_on: - db image: wordpress:latest ports: - "8080:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wpuser WORDPRESS_DB_PASSWORD: wppass working_dir: /var/www/html volumes: - ./data/wordpress:/var/www/html/wp-content
Create the docker-compose.yml-file and start the containers:
sudo docker-compose up
After starting the containers a WordPress website will be available at http://localhost:8080.
Portainer
Portainer simplifies finding and deleting unused images, containers, networks and volumes. It also provides a simple GUI to monitor and control docker containers, images, networks and volumes. It is also possible to set up new containers using portainer, although docker-compose is more popular and probably more versatile for that purpose.
Run Portainer in Docker:
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
Alternatively a docker-compose file can be used to deploy portainer:
version: '2' services: portainer: image: portainer/portainer command: -H unix:///var/run/docker.sock restart: always ports: - 9000:9000 - 8000:8000 volumes: - /var/run/docker.sock:/var/run/docker.sock - portainer_data:/data volumes: portainer_data:
The portainer UI will be available at http://localhost:9000.