31
submitted 8 months ago* (last edited 8 months ago) by boydster@sh.itjust.works to c/linux@lemmy.ml

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.

# new Docker Swarm node setup from fresh Debian Netinst

# as root, all nodes
apt install sudo
usermod -aG sudo [user]
logout

# as [user], all nodes
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 install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
sudo usermod -aG docker [user]

## Shared Storage Stuff, all nodes ##

nano ~/.smbcredentials
# paste the following:
#   username=[cluserUser]
#   password=[clusterPW]
#
# add mount point for shared storage
sudo nano /etc/fstab
# add the following to the bottom:
# /[NAS.IP.Address]/[ClusterStorageFolder]/ /home/[user]/share cifs credentials=/home/[user]/.smbcredentials 0 0

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

# on any additional nodes, paste the command copied above
docker swarm join [...all the rest of the command...]

# for each docker container, on any manager node
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
top 9 comments
sorted by: hot top controversial new old
[-] agressivelyPassive@feddit.de 3 points 8 months ago
[-] possiblylinux127@lemmy.zip 2 points 8 months ago

No, its not dead

[-] boydster@sh.itjust.works 1 points 8 months ago

Maybe, I'm a bajillion years old and have a knack for choosing poorly, but it's in the documentation still and works really well on Debian boxes for homelab services so I've been having fun with it. It also brought me into the world of Proxmox and LXC containers as the very next step on my learning journey. So, it can't be all bad, right? :)

Regardless, setting up a single Docker node is the same as setting up a cluster in terms if the initial steps, you just leave out the swarmy bits.

[-] GravitySpoiled@lemmy.ml 2 points 8 months ago

echo "you can appends this to " >> this.file

[-] clmbmb@lemmy.dbzer0.com 5 points 8 months ago

If you refer to their line doing echo "something" | tee - a /path, then it's correct. They are echoing some text into a file their user doesn't have write access to. So sudo tee - a appends to the file as root.

[-] GravitySpoiled@lemmy.ml 2 points 8 months ago
[-] boydster@sh.itjust.works 1 points 8 months ago

I see what you mean, thank you for sharing, I could make this a bash script and that is one of the changes I'd want to make to make it more user friendly for sure. For now it was mostly notes I made and felt like sharing in case it was helpful, but cleaning it up with file edits and even a menu to drop in the compose files and a screen for optional external storage integration would be a good idea

[-] GravitySpoiled@lemmy.ml 2 points 8 months ago

It's perfectly fine as it is 👍🏻

this post was submitted on 25 Feb 2024
31 points (100.0% liked)

Linux

48179 readers
973 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS