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/04/20 14:31] – [First Docker App: Portainer] Daniel | content:serverbasics:docker [2025/02/08 11:30] (aktuell) – [Update] Daniel | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== Docker (rootless) ====== | + | ====== Docker (rootless) |
- | 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 277: | Zeile 318: | ||
'' | '' | ||
- | **by default, the path and the file is not existent, | + | **by default, the path and the file is not existent, |
- | For example, enable | + | For example, enable |
< | < | ||
{ | { | ||
- | " | ||
" | " | ||
+ | " | ||
+ | " | ||
" | " | ||
" | " | ||
Zeile 293: | Zeile 335: | ||
</ | </ | ||
- | Notice: Don't use '' | + | Notice: Don't use '' |
+ | |||
+ | 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 rootless, you will not find that network as interface on your host like you would on a rootful 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 ===== | ||
- | The command '' | + | **This Chapter may be obsolete as since docker v27 the compose plugin is part of installation script - check your output of '' |
+ | |||
+ | The command '' | ||
Installing it the manual way: | Installing it the manual way: | ||
- | Edit the File '' | + | Edit the File '' |
< | < | ||
Zeile 325: | Zeile 381: | ||
Your done with the compose plugin | Your done with the compose plugin | ||
+ | |||
+ | ===== Update ===== | ||
+ | |||
+ | If you want to update your docker- installation, | ||
+ | |||
+ | < | ||
+ | #!/bin/bash | ||
+ | #Upgrade docker rootless and plugin | ||
+ | ./ | ||
+ | sleep 5 | ||
+ | systemctl --user stop docker | ||
+ | sleep 5 | ||
+ | #uninstall | ||
+ | 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:// | ||
+ | #need to give the new binary permissions to acces privileged network ports (beneath 1024) | ||
+ | sudo setcap ' | ||
+ | #this should be everything | ||
+ | docker info | ||
+ | |||
+ | </ | ||
Zeile 331: | Zeile 417: | ||
Now, that you have compose, you can use it to setup your services with YAML- Files. Each service should have a directory for its own. | Now, that you have compose, you can use it to setup your services with YAML- Files. Each service should have a directory for its own. | ||
- | Make a directory with '' | + | Make a directory with '' |
===== First Docker App: Portainer ===== | ===== First Docker App: Portainer ===== | ||
Zeile 337: | Zeile 424: | ||
As always, SSH into your docker- user and than create the folders and yml-files for docker compose and portainer. | As always, SSH into your docker- user and than create the folders and yml-files for docker compose and portainer. | ||
- | |||
< | < | ||
+ | |||
obel1x@server: | obel1x@server: | ||
Password: | Password: | ||
Zeile 395: | Zeile 482: | ||
</ | </ | ||
- | Now you can go to http:// | + | Now you can go to [[http:// |
{{ .: | {{ .: | ||
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) | ||
+ | |||
+ | </ | ||