diff options
author | Ibrahim Mkusa <ibrahimmkusa@gmail.com> | 2024-08-12 14:32:15 -0400 |
---|---|---|
committer | Ibrahim Mkusa <ibrahimmkusa@gmail.com> | 2024-08-12 14:32:15 -0400 |
commit | 56bcdb6f7dcb2785c21dcd7e6b298826c50d6c74 (patch) | |
tree | 04e7395627e6bbeefeda98357688683fc83df7cf | |
parent | 4e79ce2ab16646ff8face9438eaf4fb3a6b84ed0 (diff) |
running containers as systemd_services with podman
-rw-r--r-- | scheduling/starting_containers_as_systemd_services.md | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scheduling/starting_containers_as_systemd_services.md b/scheduling/starting_containers_as_systemd_services.md new file mode 100644 index 0000000..b9232a7 --- /dev/null +++ b/scheduling/starting_containers_as_systemd_services.md @@ -0,0 +1,30 @@ +Run a container mysql tied to port 4001 and mount user jane's mysql directory +to the containers /var/lib/mysql/ + +After set up the container to autostart on reboot regardless whether the user +logs in or not +``` +loginctl enable-linger jane # services will run regardless if user loggedin +su - jane +mkdir /home/jane/mysql/ + +podman run -d -p -n mysql 4001:4001 -v /home/jane/mysql/:/var/lib/mysql/:Z -e \ + MYSQL_ROOT_PASSWORD=password \ + quay.io/fedora/mariadb-103 #whatever container provides mysql services +podman ps -a # ensure container is running + + +``` + +If the container is running, lets make it persistent by creating a systemd user +service. Make sure you login properly to user as using `su - jane` will not +systemd. Use ssh as an alternative + +``` +mkdir -p .config/systemd/user # prep work to create systemd user service +cd /home/jane/.config/systemd/user +podman generate systemd --files --new --name mysql + +systemctl --user daemon-reload # reload for systemd to pick new service unit +systemctl --user enable container-mysql.service +``` |