{"id":18089019,"url":"https://github.com/eriksjolund/socket-activate-httpd","last_synced_at":"2026-03-19T03:13:28.465Z","repository":{"id":92823395,"uuid":"479965791","full_name":"eriksjolund/socket-activate-httpd","owner":"eriksjolund","description":"socket activated Apache httpd","archived":false,"fork":false,"pushed_at":"2022-05-21T19:16:44.000Z","size":21,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-14T05:35:46.672Z","etag":null,"topics":["container","demo","httpd","podman","socket-activation","systemd-service"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eriksjolund.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-10T09:07:55.000Z","updated_at":"2023-06-02T15:22:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"fbf7716e-0080-45cb-9cd1-c4024fba1527","html_url":"https://github.com/eriksjolund/socket-activate-httpd","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/eriksjolund/socket-activate-httpd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eriksjolund%2Fsocket-activate-httpd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eriksjolund%2Fsocket-activate-httpd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eriksjolund%2Fsocket-activate-httpd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eriksjolund%2Fsocket-activate-httpd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eriksjolund","download_url":"https://codeload.github.com/eriksjolund/socket-activate-httpd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eriksjolund%2Fsocket-activate-httpd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28919365,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T20:25:28.696Z","status":"ssl_error","status_checked_at":"2026-01-30T20:25:13.426Z","response_time":66,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["container","demo","httpd","podman","socket-activation","systemd-service"],"created_at":"2024-10-31T17:42:41.515Z","updated_at":"2026-01-30T21:03:57.425Z","avatar_url":"https://github.com/eriksjolund.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# socket-activate-httpd\n\nA demo of how to socket activate an [httpd](https://httpd.apache.org) container with Podman.\n\nWhen using socket activation, there are some changes regarding how to run `podman run`:\n\n* [`--publish`](https://docs.podman.io/en/latest/markdown/podman-run.1.html#publish-p-ip-hostport-containerport-ip-containerport-hostport-containerport-containerport) is not used\n* [`--network=none`](https://docs.podman.io/en/latest/markdown/podman-run.1.html#network-mode-net) can be used to prevent outgoing connections\n\n### Requirements\n\n* __curl__\n* __podman__  version 3.4.0 (released September 2021) or newer\n* __container-selinux__ version 2.183.0 (released April 2022) or newer\n\n(If you are using an older version of __container-selinux__ and it does not work, add `--security-opt label=disable` to `podman run`)\n\n### About the container image\n\nThe container image [__ghcr.io/eriksjolund/socket-activate-httpd__](https://github.com/eriksjolund/socket-activate-httpd/pkgs/container/socket-activate-httpd)\nis built by the GitHub Actions workflow [.github/workflows/publish_container_image.yml](.github/workflows/publish_container_image.yml)\nfrom the file [./Containerfile](./Containerfile).\n\n### Socket activate an httpd systemd user service\n\n1. Start the httpd socket unit\n    ```\n    git clone https://github.com/eriksjolund/socket-activate-httpd.git\n    mkdir -p ~/.config/systemd/user\n    cp -r socket-activate-httpd/systemd/httpd* ~/.config/systemd/user\n    systemctl --user daemon-reload\n    systemctl --user start httpd.socket\n    ```\n    The user service _httpd.service_ will be started as soon as a client connects to the listening socket.\n\n2. Run curl on the host to download a webpage from  __httpd__ in the container.\n    ```\n    $ curl -s localhost:8080 | head -6\n    \u003c!doctype html\u003e\n    \u003chtml\u003e\n      \u003chead\u003e\n\t\u003cmeta charset='utf-8'\u003e\n\t\u003cmeta name='viewport' content='width=device-width, initial-scale=1'\u003e\n\t\u003ctitle\u003eTest Page for the HTTP Server on Fedora\u003c/title\u003e\n    $\n    ```\n\n3. Try to establish an outgoing connection by running curl in the container\n    ```\n    $ podman exec -t httpd curl https://podman.io\n    curl: (6) Could not resolve host: podman.io\n    $\n    ```\n    (The command-line option `--network=none` was added to `podman run` to prevent the container from establishing outgoing connections)\n\n### Socket activate httpd with systemd-socket-activate\n\nIf you just ran the previous example, first run `systemctl --user stop httpd.service` and `systemctl --user stop httpd.socket`. The TCP port 8080 needs to be available for this example.\n\n1. Socket activate the httpd server\n    ```\n    $ systemd-socket-activate -l 8080 podman run --rm --name httpd2 --network=none ghcr.io/eriksjolund/socket-activate-httpd\n    ```\n\n2. In another shell\n    ```\n    $ curl -s localhost:8080 | head -6\n    \u003c!doctype html\u003e\n    \u003chtml\u003e\n      \u003chead\u003e\n\t\u003cmeta charset='utf-8'\u003e\n\t\u003cmeta name='viewport' content='width=device-width, initial-scale=1'\u003e\n\t\u003ctitle\u003eTest Page for the HTTP Server on Fedora\u003c/title\u003e\n    $\n    ```\n\n3. Try establishing an outgoing connection\n    ```\n    $ podman exec -t httpd2 curl https://podman.io\n    curl: (6) Could not resolve host: podman.io\n    $\n    ```\n\n### httpd socket activation configuration\n\nThe passed in sockets need to match corresponding `Listen` directives in the __httpd__ configuration.\nFor example, here the port number 8080 needs to used both in the file _httpd.conf_ and in the socket unit _httpd.socket_.\n\n```\n    $ grep 8080 systemd/httpd.socket\n    ListenStream=127.0.0.1:8080\n    $ grep 8080 Containerfile\n    RUN sed -i \"s/Listen 80/Listen 127.0.0.1:8080/g\" /etc/httpd/conf/httpd.conf\n    $\n```\n\n### Troubleshooting\n\n#### The container takes long time to start\n\nPulling a container image may take long time. This delay can be avoided by pulling the container\nimage beforehand and adding the command-line option `--pull=never` to `podman run`.\n\nA good way to diagnose problems is to look in the journald log for the service:\n\n```\njournalctl -xe --user -u httpd.service\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feriksjolund%2Fsocket-activate-httpd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feriksjolund%2Fsocket-activate-httpd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feriksjolund%2Fsocket-activate-httpd/lists"}