{"id":13998279,"url":"https://github.com/AkihiroSuda/containerized-systemd","last_synced_at":"2025-07-23T06:31:04.666Z","repository":{"id":54451095,"uuid":"239590726","full_name":"AkihiroSuda/containerized-systemd","owner":"AkihiroSuda","description":"Dockerfile examples for containerized systemd (mainly for test environments)","archived":false,"fork":false,"pushed_at":"2021-05-21T07:16:51.000Z","size":26,"stargazers_count":122,"open_issues_count":5,"forks_count":20,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-18T07:34:46.535Z","etag":null,"topics":["systemd"],"latest_commit_sha":null,"homepage":"https://github.com/moby/moby/pull/40493","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AkihiroSuda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-10T19:07:16.000Z","updated_at":"2024-09-19T07:11:06.000Z","dependencies_parsed_at":"2022-08-13T16:01:07.096Z","dependency_job_id":null,"html_url":"https://github.com/AkihiroSuda/containerized-systemd","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AkihiroSuda%2Fcontainerized-systemd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AkihiroSuda%2Fcontainerized-systemd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AkihiroSuda%2Fcontainerized-systemd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AkihiroSuda%2Fcontainerized-systemd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AkihiroSuda","download_url":"https://codeload.github.com/AkihiroSuda/containerized-systemd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227245143,"owners_count":17753239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["systemd"],"created_at":"2024-08-09T19:01:32.182Z","updated_at":"2024-11-30T00:31:22.257Z","avatar_url":"https://github.com/AkihiroSuda.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# Dockerfile examples for containerized systemd (mainly for test environments)\n\n* `Dockerfile.archlinux`: Arch Linux (systemd 247, as of Feb 2021)\n* `Dockerfile.centos-8.3`: CentOS 8.3 (systemd 239)\n* `Dockerfile.debian-10`: Debian GNU/Linux 10 (systemd 241)\n* `Dockerfile.fedora-33`: Fedora 33 (systemd 246)\n* `Dockerfile.opensuse-tumbleweed`: openSUSE Tumbleweed (systemd 246, as of Feb 2021)\n* `Dockerfile.ubuntu-20.04`: Ubuntu 20.04 (systemd 245)\n\n## Demo 1: interactive shell with `systemctl`\n\n* The command (`/bin/bash`) specified as the argument of `docker run` is executed as the foreground job in the container.\n* Workdir (`--workdir /usr`) is propagated\n* Env vars (`-e FOO=hello`) are propagated\n* The container shuts down when the command exits. The exit status code (`42`) is propagated.\n\n```console\nhost$ docker build -t foo -f Dockerfile.debian-10 .\nhost$ docker run -it --rm --privileged --workdir /usr -e FOO=hello foo /bin/bash\nCreated symlink /etc/systemd/system/docker-entrypoint.target.wants/docker-entrypoint.service → /etc/systemd/system/docker-entrypoint.service.\nCreated symlink /etc/systemd/system/systemd-firstboot.service → /dev/null.\nCreated symlink /etc/systemd/system/systemd-udevd.service → /dev/null.\n/docker-entrypoint.sh: starting /lib/systemd/systemd --show-status=false --unit=docker-entrypoint.target\nsystemd 241 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid)\nDetected virtualization docker.\nDetected architecture x86-64.\nSet hostname to \u003c4608072355e2\u003e.\n+ /bin/bash\nroot@4608072355e2:/usr# systemctl status\n● 4608072355e2\n    State: running\n     Jobs: 0 queued\n   Failed: 0 units\n    Since: Mon 2020-02-10 21:41:37 UTC; 3s ago\n   CGroup: /system.slice/docker-4608072355e222fd25bdfa4b74e48c3f087f4d8128814a29d4035e7a8e42a364.scope\n           ├─init.scope\n           │ └─1 /lib/systemd/systemd --show-status=false --unit=docker-entrypoint.target\n           └─system.slice\n             ├─systemd-journald.service\n             │ └─26 /lib/systemd/systemd-journald\n             └─docker-entrypoint.service\n               ├─38 /bin/sh -xec /bin/bash\n               ├─39 /bin/bash\n               ├─40 systemctl status\n               └─41 pager\nroot@4608072355e2:/usr# pwd\n/usr\nroot@4608072355e2:/usr# echo $FOO\nhello\nroot@4608072355e2:/usr# exit 42\nexit\nhost$ echo $?\n42\n```\n\n## Demo 2: `journalctl -f`\n\n```console\nhost$ docker run -it --rm --privileged foo journalctl -f\nCreated symlink /etc/systemd/system/docker-entrypoint.target.wants/docker-entrypoint.service → /etc/systemd/system/docker-entrypoint.service.\nCreated symlink /etc/systemd/system/systemd-firstboot.service → /dev/null.\nCreated symlink /etc/systemd/system/systemd-udevd.service → /dev/null.\n/docker-entrypoint.sh: starting /lib/systemd/systemd --show-status=false --unit=docker-entrypoint.target\nsystemd 241 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid)\nDetected virtualization docker.\nDetected architecture x86-64.\nSet hostname to \u003c827af95def7e\u003e.\n+ journalctl -f\n-- Logs begin at Wed 2020-02-12 06:20:22 UTC. --\nFeb 12 06:20:22 827af95def7e systemd[1]: Started Flush Journal to Persistent Storage.\nFeb 12 06:20:22 827af95def7e systemd[1]: Starting Create Volatile Files and Directories...\nFeb 12 06:20:22 827af95def7e systemd[1]: Started Create Volatile Files and Directories.\nFeb 12 06:20:22 827af95def7e systemd[1]: Condition check resulted in Network Time Synchronization being skipped.\nFeb 12 06:20:22 827af95def7e systemd[1]: Reached target System Time Synchronized.\nFeb 12 06:20:22 827af95def7e systemd[1]: Starting Update UTMP about System Boot/Shutdown...\nFeb 12 06:20:22 827af95def7e systemd[1]: Started Update UTMP about System Boot/Shutdown.\nFeb 12 06:20:22 827af95def7e systemd[1]: Reached target System Initialization.\nFeb 12 06:20:22 827af95def7e systemd[1]: Started docker-entrypoint.service (journalctl -f).\nFeb 12 06:20:22 827af95def7e systemd[1]: Startup finished in 410ms.\n^Cgot signal INT\nhost$ echo $?\n130\n```\n\n## Bugs\n* `docker run` needs `-t`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAkihiroSuda%2Fcontainerized-systemd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAkihiroSuda%2Fcontainerized-systemd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAkihiroSuda%2Fcontainerized-systemd/lists"}