forked from sebsauvage/Shaarli
-
Notifications
You must be signed in to change notification settings - Fork 303
Podman section for documentation #1882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tronde
wants to merge
7
commits into
shaarli:master
Choose a base branch
from
Tronde:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d04945b
Create Podman.md
Tronde 274bfdc
Update Podman.md
Tronde 12b834b
Merge branch 'shaarli:master' into master
Tronde f8ba780
Use full qualified path with release tag
Tronde 407e40e
Use full qualified path with release tag
Tronde 8619dd9
Merge branch 'shaarli:master' into master
Tronde 4a59c91
Set correct file ownership for podman volumes
Tronde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| # Podman | ||
|
|
||
| [Podman](https://docs.podman.io/en/latest/) is a daemonless container engine for developing, managing, and running OCI Containers on your Linux System. Containers can either be run as root or in rootless mode. | ||
|
|
||
| ## Install Podman | ||
|
|
||
| [Install Podman](https://podman.io/getting-started/installation), by following the instructions relevant to your OS / distribution. For example on Debian: | ||
|
|
||
| ~~~ | ||
| sudo apt-get -y install podman | ||
| ~~~ | ||
|
|
||
| *The podman package is available in the Debian 11 (Bullseye) repositories and later.* | ||
|
|
||
| ## Setup Podman | ||
|
|
||
| The following two tutorials show you how to set up Podman and perform some basic commands with the utility: | ||
|
|
||
| * [Basic Setup and Use of Podman](https://github.com/containers/podman/blob/main/docs/tutorials/podman_tutorial.md) | ||
| * [Basic Setup and Use of Podman in a Rootless environment](https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md) | ||
|
|
||
| ## Get and run a Shaarli image | ||
|
|
||
| Shaarli images are available on [DockerHub](https://hub.docker.com/r/shaarli/shaarli/) `shaarli/shaarli`: | ||
|
|
||
| - `latest`: master (development) branch | ||
| - `vX.Y.Z`: shaarli [releases](https://github.com/shaarli/Shaarli/releases) | ||
| - `release`: always points to the last release **Note:** Currently broken. See issue [#1875](https://github.com/shaarli/Shaarli/issues/1875). Use `stable` instead. | ||
| - `stable` and `master`: **deprecated**. These tags are no longer maintained and may be removed without notice | ||
|
|
||
| These images are built automatically on DockerHub and rely on: | ||
|
|
||
| - [Alpine Linux](https://www.alpinelinux.org/) | ||
| - [PHP7-FPM](http://php-fpm.org/) | ||
| - [Nginx](http://nginx.org/) | ||
|
|
||
| Here is an example of how to run Shaarli latest image using Podman: | ||
|
|
||
| ```bash | ||
| # download the image from dockerhub | ||
| podman pull docker.io/shaarli/shaarli:release | ||
|
|
||
| # create persistent data volumes/directories on the host | ||
| podman volume create shaarli-data | ||
| podman volume create shaarli-cache | ||
|
|
||
| # Since the NGINX process in the container is running with UID 100 and GID 101 the | ||
| # UID and GID for the volumes just created have to adjusted in the user namespace. | ||
| # For detailed information see podman-unshare(1). | ||
| podman unshare chown 100:101 -R \ | ||
| .local/share/containers/storage/volumes/shaarli-{cache,data} | ||
|
|
||
| # create a new container using the Shaarli image | ||
| # --detach: run the container in background | ||
| # --name: name of the created container/instance | ||
| # --publish: map the host's :8000 port to the container's :80 port | ||
| # --rm: automatically remove the container when it exits | ||
| # --volume: mount persistent volumes in the container ($volume_name:$volume_mountpoint) | ||
| podman run --detach \ | ||
| --name myshaarli \ | ||
| --publish 8000:80 \ | ||
| --rm \ | ||
| --volume shaarli-data:/var/www/shaarli/data \ | ||
| --volume shaarli-cache:/var/www/shaarli/cache \ | ||
| docker.io/shaarli/shaarli:release | ||
|
|
||
| # verify that the container is running | ||
| podman ps | grep myshaarli | ||
|
|
||
| # to completely remove the container | ||
| podman stop myshaarli # stop the running container | ||
| podman ps | grep myshaarli # verify the container is no longer running | ||
| podman ps -a | grep myshaarli # verify the container is stopped | ||
| podman rm myshaarli # destroy the container | ||
| podman ps -a | grep myshaarli # verify th container has been destroyed | ||
| ``` | ||
|
|
||
| After running `podman run` command, your Shaarli instance should be available on the host machine at [localhost:8000](http://localhost:8000/). In order to access your instance through a reverse proxy, see [reverse proxy](https://shaarli.readthedocs.io/en/master/Reverse-proxy/). | ||
Tronde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| In case you are running a rootless podman setup, you have to make sure that the process (PID) inside the container has write access to your podman volumes. | ||
Tronde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Generating systemd service units for containerized Shaarli | ||
|
|
||
| Podman is able to create a systemd unit file that can be used to control a container or pod (see podman-generate-systemd(1). Example: | ||
|
|
||
| ~~~ | ||
| $ podman generate systemd --new -n -f my-shaarli | ||
| ~~~ | ||
|
|
||
| The command creates the following systemd unit file: | ||
|
|
||
| ~~~ | ||
| # container-my-shaarli.service | ||
| # autogenerated by Podman 3.0.1 | ||
| # Tue Aug 23 22:39:30 CEST 2022 | ||
|
|
||
| [Unit] | ||
| Description=Podman container-my-shaarli.service | ||
| Documentation=man:podman-generate-systemd(1) | ||
| Wants=network.target | ||
| After=network-online.target | ||
|
|
||
| [Service] | ||
| Environment=PODMAN_SYSTEMD_UNIT=%n | ||
| Restart=on-failure | ||
| TimeoutStopSec=70 | ||
| ExecStartPre=/bin/rm -f %t/container-my-shaarli.pid %t/container-my-shaarli.ctr-id | ||
| ExecStart=/usr/bin/podman run --conmon-pidfile %t/container-my-shaarli.pid --cidfile %t/container-my-shaarli.ctr-id --cgroups=no-conmon --replace --detach --name my-shaarli --publish 127.0.0.1:8001:80 --rm --volume shaarli-data:/var/www/shaarli/data:rw,nodev,noexec --volume shaarli-cache:/var/www/shaarli/cache:rw,nodev,noexec shaarli/shaarli:stable | ||
| ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-my-shaarli.ctr-id -t 10 | ||
| ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-my-shaarli.ctr-id | ||
| PIDFile=%t/container-my-shaarli.pid | ||
| Type=forking | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target default.target | ||
| ~~~ | ||
|
|
||
| This unit could be installed by copying it to an appropriate location and reloading your daemons, e.g.: | ||
|
|
||
| ~~~ | ||
| $ mv container-my-shaarli.service ~/.config/systemd/user.control/ | ||
| $ systemctl --user daemon-reload | ||
| $ podman stop my-shaarli | ||
| $ systemctl --user start container-my-shaarli.service | ||
| ~~~ | ||
|
|
||
| Now, you are able to control your Shaarli container like any other systemd service. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.