content:serverbasics:docker
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| Beide Seiten, vorherige ÜberarbeitungVorherige ÜberarbeitungNächste Überarbeitung | Vorherige Überarbeitung | ||
| content:serverbasics:docker [2024/04/20 16:31] – [First Docker App: Portainer] obel1x | content:serverbasics:docker [2026/03/01 11:44] (aktuell) – [Fast Stop of all Containers] obel1x | ||
|---|---|---|---|
| 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)!**__ | ||
| + | |||
| + | A short hint: Docker rootless uses Sub(g)uids, which is a feature of Linux. That means each user has a range of userids (quite a huge range) and groupid which the user may use. Those will be exclusive reserved for that user. But it does not mean, that the User can acces the Files created by those Subuids! Also the UIDs are onyl a number - not a real user in Linux having a username- They cannot be used to logon or to work with. Docker manages internally which Host-Subuserid is assigned to which caontainer and to which userid inside the running container/ | ||
| + | |||
| + | ===== Which Devices / Raid- Level ===== | ||
| + | |||
| + | I strongly do not advise to use Raid5 with classical harddrives to run docker on it. If you plan to have large Data in / | ||
| - | __**STRONG WARNING: Don't change permissions or ownership of docker- | + | For me, i switched to RAID1 on SSD an mounted that to /home/docker/ |
| - | __**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 49: | ||
| ===== 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 276: | ||
| | | ||
| + | </ | ||
| + | |||
| + | ==== 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 308: | ||
| </ | </ | ||
| - | 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 324: | ||
| '' | '' | ||
| - | **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 343: | ||
| </ | </ | ||
| - | 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:// | ||
| + | |||
| + | |||
| + | ==== The default Network is not IPV6- enabled by default ==== | ||
| + | |||
| + | If you specify no network, or use the network: default - than as the time of writing, IPV6 will not be enabled by default. | ||
| + | |||
| + | So, in your docker-compose.yml you need the lines: | ||
| + | < | ||
| + | |||
| + | networks: | ||
| + | # Still needs to be defined while without it won't enable ipv6 | ||
| + | default: | ||
| + | driver: bridge | ||
| + | enable_ipv6: | ||
| + | |||
| + | </ | ||
| + | |||
| + | ===== 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. | ||
| + | |||
| + | ===== Performance ===== | ||
| + | |||
| + | when you install pasta- networking driver, you can edit your docker systemd and use a much improved networking-driver. | ||
| + | |||
| + | Also you can make Docker a higher Priority and Nice-Value: | ||
| + | |||
| + | < | ||
| + | docker@server: | ||
| + | |||
| + | [Service] | ||
| + | # Higher Prio for Docker | ||
| + | Nice=10 | ||
| + | IOSchedulingClass=best-effort | ||
| + | IOSchedulingPriority=7 | ||
| + | # Use Pasta- network Driver (of your Host - Pasta needs to be installed) | ||
| + | Environment=" | ||
| + | Environment=" | ||
| + | Environment=" | ||
| + | |||
| + | </ | ||
| ===== 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 326: | Zeile 427: | ||
| 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 | ||
| + | |||
| + | </ | ||
| ===== Create a place for Yamls ===== | ===== Create a place for Yamls ===== | ||
| Zeile 331: | Zeile 461: | ||
| 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 468: | ||
| 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 526: | ||
| </ | </ | ||
| - | 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) | ||
| + | |||
| + | </ | ||
| + | ===== Find the latest Commit in git ===== | ||
| + | |||
| + | Sometimes the Repository does not offer a latest Tatg, so its hard to find the right Tag to use. Maybe this coding helps (not testet wheter to get the right commitid for the Image): | ||
| + | |||
| + | < | ||
| + | if [ -z ${TVHEADEND_COMMIT+x} ]; then \ | ||
| + | TVHEADEND_COMMIT=$(curl -sX GET https:// | ||
| + | | jq -r '. | .sha' | ||
| + | fi && \ | ||
| + | |||
| + | </ | ||
content/serverbasics/docker.1713623465.txt.gz · Zuletzt geändert: von obel1x
