{"id":1180,"date":"2023-02-27T12:00:00","date_gmt":"2023-02-27T20:00:00","guid":{"rendered":"https:\/\/letsbuildroboticswithshadow8472.com\/?p=1180"},"modified":"2023-02-27T11:02:11","modified_gmt":"2023-02-27T19:02:11","slug":"my-podman-containers-boot-with-systemd","status":"publish","type":"post","link":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/2023\/02\/27\/my-podman-containers-boot-with-systemd\/","title":{"rendered":"My Podman Containers Boot With Systemd"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Good Morning from my Robotics Lab! This is Shadow_8472 and today I am reasonably sure my Podman containers won\u2019t be randomly going down anymore. Let\u2019s get started!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I enjoy using Podman as a stand-in for Docker, but its rootless approach to running containers inherently challenges sysadmins facing Docker\u2019s help and tutorial legacy. The most problematic difference I\u2019ve experienced has been keeping containers running long-term. Months ago, I learned how to enable account lingering. This allows Podman containers without something remaining logged in as their respective users. I\u2019ve been living with manually restarting containers as needed. Well, since I decided to enable automatic security updates, starting containers automatically would be prudent before expecting other family members to rely on them.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Against all odds, my initial search this past Wednesday yielded a blog article from Red Hat about integrating Podman containers into Systemd [1] to start them at boot. It was posted the day before.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Podman and Systemd<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">I trust Red Hat to not post malicious commands, but it\u2019s still a good idea to learn about strange commands before running them. Red Hat\u2019s tutorial starts with making a new user, enabling linger, and running a containerized web server. The first important command I ran was<\/p>\n\n\n\n<pre class=\"wp-block-verse\">$ podman stop httpd &amp;&amp; podman rm -a &amp;&amp; podman volume prune<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command appears to thoroughly clean out Podman. I\u2019ve mounted volumes from the host before to persist data, but there\u2019s a more flexible volume structure I only learned about just now when researching for another section I had to spin off into a near-future post. I haven\u2019t used them yet, but I\u2019m sure they\u2019ll be useful once I learn how to use them.<\/p>\n\n\n\n<pre class=\"wp-block-verse\">$ podman generate systemd --new --files --name httpd<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command makes a new systemd file. The &#8211;new option recreates the container fresh each time it\u2019s brought online. &#8211;files sends the configuration to a file instead of the terminal. &#8211;name must be the name of a running container or pod.<\/p>\n\n\n\n<pre class=\"wp-block-verse\">$ cp -Z container-httpd.service ~\/.config\/systemd\/user\/<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The file generated previously goes in a directory where systemd will find it when used with the &#8211;user flag. The -Z flag matches permissions with the destination directory. The tutorial finishes with a daemon-reload followed by starting and enabling the user\u2019s service.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Takeaway<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is a resource for my bookmarks. That is all.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Final Question<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">I took the opportunity during this project to put a Minetest server on ButtonMash, but I\u2019m having difficulty obtaining permissions. I can see its logs in Cockpit-Podman, but I don\u2019t have access to the server command line. How am I supposed to get started with adminning Minetest?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I look forward hearing your answers in the comments below or on my <a rel=\"noreferrer noopener\" href=\"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/discord-invite\/\" target=\"_blank\">Socials<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Work Cited<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">[1] A. Oliveira, \u201cConfigure a container to start automatically as a systemd service,\u201d<em>redhat.com<\/em>,Feb. 21, 2023. [Online]. Available: <a href=\"https:\/\/www.redhat.com\/sysadmin\/container-systemd-persist-reboot\">https:\/\/www.redhat.com\/sysadmin\/container-systemd-persist-reboot<\/a> [Accessed Feb. 27, 2023].<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Good Morning from my Robotics Lab! This is Shadow_8472 and today I am reasonably sure my Podman containers won\u2019t be randomly going down anymore. Let\u2019s get started! I enjoy using Podman as a stand-in for Docker, but its rootless approach to running containers inherently challenges sysadmins facing Docker\u2019s help and tutorial legacy. The most problematic &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/2023\/02\/27\/my-podman-containers-boot-with-systemd\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;My Podman Containers Boot With Systemd&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[2,90],"tags":[138,209,55],"class_list":["post-1180","post","type-post","status-publish","format-standard","hentry","category-linux","category-red-hat-server","tag-podman","tag-restarting-containers","tag-systemd"],"_links":{"self":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts\/1180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/comments?post=1180"}],"version-history":[{"count":2,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts\/1180\/revisions"}],"predecessor-version":[{"id":1183,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts\/1180\/revisions\/1183"}],"wp:attachment":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/media?parent=1180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/categories?post=1180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/tags?post=1180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}