Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
gentoo:containers [2024/09/11 08:45] – [Podman] willy | gentoo:containers [2025/03/13 13:25] (current) – [Using Containers on Gentoo] willy | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Using Containers on Gentoo ====== | + | ====== |
Containers are a great tool that caters to some specific, and important, needs. But be aware that // | Containers are a great tool that caters to some specific, and important, needs. But be aware that // | ||
Line 79: | Line 79: | ||
which i suggest to run as un-priviledged user to verify everything is working as non-root too. | which i suggest to run as un-priviledged user to verify everything is working as non-root too. | ||
- | Now, install **podman-compose** | + | Now, install **podman-compose**, and thanks to a few user contributed inputs (see [[https://bugs.gentoo.org/717748]]), mine included, it's not part of portage gentoo tree, so: |
- | + | <code bash> | |
- | Follow my [[gentoo: | + | emerge |
- | <file - podman-compose-1.0.6.ebuild> | + | </code> |
- | # Copyright 2024 Gentoo Authors | + | |
- | # Distributed under the terms of the GNU General Public License v2 | + | |
- | + | ||
- | EAPI=8 | + | |
- | + | ||
- | DISTUTILS_USE_SETUPTOOLS=rdepend | + | |
- | PYTHON_COMPAT=( python3_{10..11} ) | + | |
- | + | ||
- | inherit distutils-r1 | + | |
- | + | ||
- | DESCRIPTION=" | + | |
- | HOMEPAGE=" | + | |
- | SRC_URI=" | + | |
- | # | + | |
- | + | ||
- | LICENSE=" | + | |
- | SLOT=" | + | |
- | KEYWORDS=" | + | |
- | + | ||
- | DEPEND="" | + | |
- | RDEPEND=" | + | |
- | ${DEPEND} | + | |
- | dev-python/ | + | |
- | dev-python/ | + | |
- | " | + | |
- | BDEPEND="" | + | |
- | </file> | + | |
- | + | ||
- | as //app-containers/podman-compose-1.0.6.ebuild// and then emerge it (see [[https:// | + | |
- | I hope that this ebuild will be merged to Gentoo official repo soon. | + | beware |
=== Podman rootless users === | === Podman rootless users === | ||
Line 132: | Line 103: | ||
To create a Podman subnet you need to run the following command after each reboot, as root: | To create a Podman subnet you need to run the following command after each reboot, as root: | ||
<code bash> | <code bash> | ||
- | > | + | podman network create my-container-net |
</ | </ | ||
Line 152: | Line 123: | ||
networks: | networks: | ||
my-container-net: | my-container-net: | ||
- | | + | </ |
| | ||
- | | + | I strongly suggest that you edit your docker compose files and ensure each service has it's own independent network. I will give more details for each service on it's respective page. |
Line 173: | Line 144: | ||
UC_SLOT=" | UC_SLOT=" | ||
UC_USER=${USER: | UC_USER=${USER: | ||
+ | UC_COMPOSER_FILE=${COMPOSER_FILE: | ||
+ | UC_CHOWN_DIR=${CHOWN_DIR} | ||
if [ " | if [ " | ||
then | then | ||
UC_HOME=${HOME: | UC_HOME=${HOME: | ||
fi | fi | ||
+ | |||
+ | extra_commands=" | ||
+ | update() { | ||
+ | if [ " | ||
+ | then | ||
+ | COMMAND=" | ||
+ | stop | ||
+ | ebegin " | ||
+ | su - ${UC_USER} -c " | ||
+ | start | ||
+ | else | ||
+ | ebegin " | ||
+ | eend 255 | ||
+ | fi | ||
+ | } | ||
description=${DESCRIPTION: | description=${DESCRIPTION: | ||
Line 184: | Line 172: | ||
if [ " | if [ " | ||
then | then | ||
- | test -e " | + | |
- | | + | test -e " |
- | | + | mkdir " |
- | | + | } && chown -R ${UC_USER} " |
+ | if [ -n " | ||
+ | then | ||
+ | chown -R ${UC_USER} ${UC_CHOWN_DIR} | ||
+ | fi | ||
else | else | ||
ebegin " | ebegin " | ||
Line 193: | Line 185: | ||
fi | fi | ||
} | } | ||
+ | |||
start() { | start() { | ||
ebegin " | ebegin " | ||
COMMAND=" | COMMAND=" | ||
- | ARGUMENTS=(compose up) | + | ARGUMENTS=(compose |
ebegin " ... ensuring nat table is loaded ..." | ebegin " ... ensuring nat table is loaded ..." | ||
iptables -L -t nat &> /dev/null | iptables -L -t nat &> /dev/null | ||
ebegin " ... creating ' | ebegin " ... creating ' | ||
podman network create ${UC_SLOT}-net &> /dev/null | podman network create ${UC_SLOT}-net &> /dev/null | ||
- | ebegin " ... running a ' | ||
su - " | su - " | ||
start-stop-daemon -p ${pidfile} \ | start-stop-daemon -p ${pidfile} \ | ||
Line 217: | Line 209: | ||
stop() { | stop() { | ||
ebegin " ... running ' | ebegin " ... running ' | ||
- | su - " | + | su - " |
start-stop-daemon -p ${pidfile} \ | start-stop-daemon -p ${pidfile} \ | ||
-u ${UC_USER} \ | -u ${UC_USER} \ | ||
Line 244: | Line 236: | ||
</ | </ | ||
- | That's it. | + | That's it. |
+ | |||
+ | The above script also provide an " | ||
==== Using Podman for new containers ==== | ==== Using Podman for new containers ==== |