Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
content:serverbasics:docker [2024/05/18 11:11] – [Update] Daniel | content:serverbasics:docker [2025/02/08 11:30] (aktuell) – [Update] Daniel | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
====== Docker (rootless) + Portainer ====== | ====== Docker (rootless) + Portainer ====== | ||
- | Docker is a powerful solution for setting up Services. This on will give you hints how to setup Docker in a good way. | + | Docker is a powerful solution for setting up Services. This short Introducion |
- | Currently i am Experimenting | + | Currently i am experimenting |
Docker itself is nice, but it will run as root per default, which is a no-go at all. This will setup Docker in rootless- mode on OpenSuSE (currently Leap 15.5). | Docker itself is nice, but it will run as root per default, which is a no-go at all. This will setup Docker in rootless- mode on OpenSuSE (currently Leap 15.5). | ||
+ | |||
+ | __**Warning: | ||
+ | |||
+ | So just: Don't set up Docker rootfull at all if possible - its even not neeeded nowadays. | ||
===== Filesystem Layout ===== | ===== Filesystem Layout ===== | ||
- | Mind, that at the time writing, '' | + | Mind, that at the time writing, '' |
- | I personally dislike xfs, especially while its not rubust and won't shrink. I use it anyway, because of its srong advise to do so - with kernel 5.19+ it should be possible to get overlay2 working on btrfs, but still there are thinks | + | I personally dislike xfs, especially while its not rubust and won't shrink. I use it anyway, because of its srong advise to do so - with kernel 5.19+ it should be possible to get overlay2 working on btrfs, but still there are things |
So make sure, that the Home-Directory of you docker user is on XFS. The ftype is already ok on SuSE 15.5, check output of '' | So make sure, that the Home-Directory of you docker user is on XFS. The ftype is already ok on SuSE 15.5, check output of '' | ||
- | Warning: you may have umask set your way - i prefer 007 as writte | + | Warning: you may have umask set your way - i prefer 007 as written |
+ | |||
+ | That may change the ownership in a way, that even the docker user on the host cannot access the Files, which is OK ! | ||
+ | |||
+ | __**STRONG WARNING: Don't change permissions or ownership of docker- directories on the Host directly as this will change them in the container, making them unavaiable and break your Services !!!**__ | ||
+ | |||
+ | __**The only way to manage Volume- File- Permissions is to bash inside the running container itself and to change them there (to the right values of course)!**__ | ||
- | __**STRONG WARNING: Don't change permissions or ownership | + | A short hint: Docker rootless uses Sub(g)uids, which is a feature |
- | __**The only way to manage Volume- File- Permissions is to bash inside the running container itself and to change them there!**__ | ||
===== Packages NOT to install ===== | ===== Packages NOT to install ===== | ||
- | I had really a lot of troubles with the package in the AddOn- Repository: '' | + | I had really a lot of troubles with the package |
So i disabled the following packages and locked them to never install: | So i disabled the following packages and locked them to never install: | ||
Zeile 34: | Zeile 43: | ||
===== Docker- User ===== | ===== Docker- User ===== | ||
- | Create a new **group** | + | Create a new **group** |
Attention: The Home Directory should be on a volume having XFS as btrfs or others are not fully supported right now (20.04.2024 - patches in new Kernel 5.19 are incoming, but this Kernel is not released until now and still there are some problems open in developement there). | Attention: The Home Directory should be on a volume having XFS as btrfs or others are not fully supported right now (20.04.2024 - patches in new Kernel 5.19 are incoming, but this Kernel is not released until now and still there are some problems open in developement there). | ||
Zeile 261: | Zeile 270: | ||
| | ||
+ | </ | ||
+ | |||
+ | ==== Additional knowledge ==== | ||
+ | |||
+ | * Storage driver and FS-Type : overlay2 should always be used, btrfs is outdated! XFS and d_type are important! | ||
+ | * CGroup Version needs to be 2 or better | ||
+ | * If you see Docker complaining about Module aufs at start: do not care about - that module is obsolete | ||
+ | |||
+ | ===== IP-Filter ===== | ||
+ | |||
+ | When starting Docker, an the log says: | ||
+ | |||
+ | < | ||
+ | level=warning msg=" | ||
+ | level=info msg=" | ||
+ | |||
+ | </ | ||
+ | |||
+ | You first need to load the module with modprobe. | ||
+ | |||
+ | For system startup, use ''/ | ||
+ | |||
+ | ===== IPTables ===== | ||
+ | |||
+ | If you see '' | ||
+ | |||
+ | < | ||
WARNING: bridge-nf-call-iptables is disabled | WARNING: bridge-nf-call-iptables is disabled | ||
WARNING: bridge-nf-call-ip6tables is disabled | WARNING: bridge-nf-call-ip6tables is disabled | ||
Zeile 266: | Zeile 302: | ||
</ | </ | ||
- | Important things: | + | This should be fixed by: |
- | * Storage driver and FS-Type : overlay2 should always be used, btrfs is outdated! XFS and d_type are important! | + | < |
- | * CGroup Version needs to be 2 or better | + | # sudo echo " |
+ | # sudo echo " | ||
+ | # sudo modprobe br_netfilter | ||
+ | # sudo sysctl --system | ||
+ | |||
+ | </ | ||
===== Configuring Docker Daemon ===== | ===== Configuring Docker Daemon ===== | ||
Zeile 283: | Zeile 324: | ||
{ | { | ||
- | " | ||
" | " | ||
" | " | ||
Zeile 295: | Zeile 335: | ||
</ | </ | ||
- | You need to adjust cidr to match your network, check first 4 blocks of '' | + | Notice: Don't use '' |
- | Notice: Don' | + | Edit: " |
+ | |||
+ | You need to adjust cidr to some unique ULA. ULAs are non internet routable adresses (like 192.X.X.X in ipv4). Select an unique adress only for that internal Docker network - you can choose anything that is not assigned anywhere else on your network to not cause trouble. | ||
+ | |||
+ | Maybe use this tool to generate: [[https:// | ||
+ | |||
+ | ===== Networking in Docker rootless ===== | ||
+ | |||
+ | If you read docs in the net about networking with Docker you may see docker0 as bridge network. While this network is also there in docker | ||
+ | |||
+ | Instead the network is encapsulated in the environement of rootlesskit and not visible to the host. From the Hosts view Docker is just another Application running on your Host talking to the internet like some app would do. | ||
===== Install docker compose ===== | ===== Install docker compose ===== | ||
+ | |||
+ | **This Chapter may be obsolete as since docker v27 the compose plugin is part of installation script - check your output of '' | ||
The command '' | The command '' | ||
Zeile 337: | Zeile 389: | ||
#!/bin/bash | #!/bin/bash | ||
#Upgrade docker rootless and plugin | #Upgrade docker rootless and plugin | ||
+ | ./ | ||
+ | sleep 5 | ||
systemctl --user stop docker | systemctl --user stop docker | ||
+ | sleep 5 | ||
+ | #uninstall | ||
rm -f ~/ | rm -f ~/ | ||
+ | rm ~/ | ||
+ | mv ~/ | ||
+ | #reinstall docker compose | ||
+ | COMPOSE_VER=' | ||
+ | rm $DOCKER_CONFIG/ | ||
+ | echo " | ||
+ | curl -SL https:// | ||
+ | chmod +x $DOCKER_CONFIG/ | ||
+ | #install docker | ||
curl -fsSL https:// | curl -fsSL https:// | ||
#need to give the new binary permissions to acces privileged network ports (beneath 1024) | #need to give the new binary permissions to acces privileged network ports (beneath 1024) | ||
sudo setcap ' | sudo setcap ' | ||
- | + | #this should be everything | |
- | # If you installed docker compose, check the newest version first at https:// | + | docker |
- | curl -SL https:// | + | |
</ | </ | ||
Zeile 423: | Zeile 487: | ||
Thats all: Docker is running and serving your services, cheers! | Thats all: Docker is running and serving your services, cheers! | ||
+ | |||
+ | ===== Fast Stop of all Containers ===== | ||
+ | |||
+ | This makes life easy '' | ||
+ | < | ||
+ | |||
+ | #!/bin/bash | ||
+ | docker stop $(docker ps -a -q) | ||
+ | docker rm $(docker ps -a -q) | ||
+ | |||
+ | </ | ||