Setting up a new Debian Docker Swarm

submitted by boydster

After seeing someone else posting their struggles with getting Docker running on their system, I thought I might share my process for setting up new Docker nodes. I don't make any representations about my way being the right way, or the best way, but this way has been working for me. I have been playing around with a swarm, but if you aren't setting up a swarm you can just omit the swarm commands and some of the firewall allows (keep what you need open, obviously, like 22 for SSH if you're using it). Similarly, if you aren't connecting to a NAS, you can leave out the part about mounting external storage.

```

apt install sudo usermod -aG sudo [user] logout

sudo apt update sudo apt upgrade -y sudo apt install fail2ban rkhunter ufw unattended-upgrades ca-certificates curl -y sudo ufw allow 22 sudo ufw allow 2377 sudo ufw allow 7946 sudo ufw allow 4789 sudo ufw enable sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y sudo usermod -aG docker [user]

nano ~/.smbcredentials

#

sudo nano /etc/fstab

docker swarm init --advertise-address # copy the join command, we'll need it next

docker swarm join [...all the rest of the command...]

mkdir ~/share/[serviceName]
cd ~/share/[serviceName] # copy relevant compose.yml into the folder # if necessary, also create any needed directories docker compose up -d docker compose down docker stack deploy -c compose.yml ```

Log in to comment