Install Docker and Docker Compose#
Update and install necessary software
apt-get update && apt-get install -y wget vim
Install Docker for non-mainland users
wget -qO- get.docker.com | bash
Note: If "sudo: unable to resolve host [hostname]" appears, you can edit nano /etc/hosts and then add a space after localhost, followed by the content of your corresponding hostname.
Check Docker version
Uninstall Docker
sudo apt-get purge docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
Install Docker Compose for non-mainland users
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Check if installed docker-compose --version
Modify Docker configuration (from Shao Bing's blog) https://u.sb/debian-install-docker/
The following configuration will add a custom internal IPv6 address, enable IPv6 functionality for containers, and limit the size of log files to prevent Docker logs from filling up the hard drive:
cat > /etc/docker/daemon.json <<EOF
{
"log-driver": "json-file",
"log-opts": {
"max-size": "20m",
"max-file": "3"
},
"ipv6": true,
"fixed-cidr-v6": "fd00:dead:beef:c0::/80",
"experimental":true,
"ip6tables":true
}
EOF
Then restart the Docker service: systemctl restart docker
Article source: 【Docker Series】You Can Play with VPS Servers Without Using Baota Panel, Even If You Are a Novice! (laoda.de)