Skip to content

Commit a8c1ce8

Browse files
committed
doc: refactor/simplify docker documentation
- do not duplicate docker install documentation - add a note about docker group membership being equivalent to root privileges - OCI images are now suitable for amd64 and arm/v7 and arm64 architectures - simplify deleting the shaarli container (since it was started with --rm) - wording - use bind mountpoint in /opt/shaarli in examples, no longer use named volumes - fix WARNING: Non-consecutive header level increase - preparation for mixed docker/podman setup documentation shaarli#1882
1 parent 4884dec commit a8c1ce8

File tree

2 files changed

+51
-76
lines changed

2 files changed

+51
-76
lines changed

doc/md/Docker.md

Lines changed: 48 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,19 @@
11

22
# Docker
33

4-
[Docker](https://docs.docker.com/get-started/overview/) is an open platform for developing, shipping, and running applications
4+
[Docker](https://docs.docker.com/get-started/overview/) is an open platform for developing, shipping, and running applications in lightweight containers.
55

66
## Install Docker
77

8-
Install [Docker](https://docs.docker.com/engine/install/), by following the instructions relevant to your OS / distribution, and start the service. For example on [Debian](https://docs.docker.com/engine/install/debian/):
8+
Install [Docker](https://docs.docker.com/engine/install/), by following the instructions relevant to your OS / distribution, and start the service.
99

10-
```bash
11-
# update your package lists
12-
sudo apt update
13-
# remove old versions
14-
sudo apt-get remove docker docker-engine docker.io containerd runc
15-
# install requirements
16-
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
17-
# add docker's GPG signing key
18-
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
19-
# add the repository
20-
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
21-
# install docker engine
22-
sudo apt-get update
23-
sudo apt-get install docker-ce docker-ce-cli containerd.io
24-
# Start and enable Docker service
25-
sudo systemctl enable docker && sudo systemctl start docker
26-
# verify that Docker is properly configured
27-
sudo docker run hello-world
28-
```
29-
30-
In order to run Docker commands as a non-root user, you must add the `docker` group to this user:
10+
_Optional:_ In order to run Docker commands as a non-root user (i.e. without `sudo`), you must add your user account to the `docker` group. Keep in mind that this effectively gives this user account [full root privileges](https://docs.docker.com/engine/security/#docker-daemon-attack-surface), without password.
3111

3212
```bash
33-
# Add docker group as secondary group
13+
# add your user to the docker group
3414
sudo usermod -aG docker your-user
35-
# Reboot or logout
36-
# Then verify that Docker is properly configured, as "your-user"
15+
# reboot or logout
16+
# then verify that Docker is properly configured, as "your-user"
3717
docker run hello-world
3818
```
3919

@@ -48,20 +28,25 @@ Shaarli images are available on [GitHub Container Registry](https://github.com/s
4828
These images are built automatically on Github Actions and rely on:
4929

5030
- [Alpine Linux](https://www.alpinelinux.org/)
51-
- [PHP7-FPM](https://php-fpm.org/)
31+
- [PHP-FPM](https://php-fpm.org/)
5232
- [Nginx](https://nginx.org/)
5333

34+
These images are suitable for the `amd64`, `arm/v7` and `arm64` CPU architectures.
35+
36+
```{note}
5437
Additional Dockerfiles are provided for the `arm32v7` platform, relying on [Linuxserver.io Alpine armhf images](https://hub.docker.com/r/lsiobase/alpine.armhf/). These images must be built using [`docker build`](https://docs.docker.com/engine/reference/commandline/build/) on an `arm32v7` machine or using an emulator such as [qemu](https://blog.balena.io/building-arm-containers-on-any-x86-machine-even-dockerhub/).
38+
```
5539

56-
Here is an example of how to run Shaarli latest image using Docker:
40+
To run the `latest` Shaarli image using Docker:
5741

5842
```bash
5943
# download the 'latest' image from GitHub Container Registry
60-
docker pull ghcr.io/shaarli/shaarli
44+
docker pull ghcr.io/shaarli/shaarli:latest
6145

62-
# create persistent data volumes/directories on the host
63-
docker volume create shaarli-data
64-
docker volume create shaarli-cache
46+
# create directories for persistent data/cache storage
47+
sudo mkdir /opt/shaarli
48+
sudo mkdir /opt/shaarli/data
49+
sudo mkdir /opt/shaarli/cache
6550

6651
# create a new container using the Shaarli image
6752
# --detach: run the container in background
@@ -73,63 +58,57 @@ docker run --detach \
7358
--name myshaarli \
7459
--publish 8000:80 \
7560
--rm \
76-
--volume shaarli-data:/var/www/shaarli/data \
77-
--volume shaarli-cache:/var/www/shaarli/cache \
61+
--volume /opt/shaarli/data:/var/www/shaarli/data \
62+
--volume /opt/shaarli/cache:/var/www/shaarli/cache \
7863
ghcr.io/shaarli/shaarli:latest
7964

8065
# verify that the container is running
8166
docker ps | grep myshaarli
67+
```
8268

83-
# to completely remove the container
84-
docker stop myshaarli # stop the running container
85-
docker ps | grep myshaarli # verify the container is no longer running
86-
docker ps -a | grep myshaarli # verify the container is stopped
87-
docker rm myshaarli # destroy the container
88-
docker ps -a | grep myshaarli # verify th container has been destroyed
69+
Your Shaarli instance should be available on the host machine at [http://localhost:8000](http://localhost:8000). In order to access your instance through a reverse proxy, we recommend using our [Docker Compose](#docker-compose) build.
8970

90-
```
71+
Stopping the container will also completely remove it (but not persistent volumes) since it was started with `--rm`:
9172

92-
After running `docker 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, we recommend using our [Docker Compose](#docker-compose) build.
73+
```bash
74+
docker stop myshaarli # stop the running container
75+
docker ps -a | grep myshaarli # verify the container has been destroyed
76+
```
9377

9478
## Docker Compose
9579

9680
A [Compose file](https://docs.docker.com/compose/compose-file/) is a common format for defining and running multi-container Docker applications.
9781

98-
A `docker-compose.yml` file can be used to run a persistent/autostarted shaarli service using [Docker Compose](https://docs.docker.com/compose/) or in a [Docker stack](https://docs.docker.com/engine/reference/commandline/stack_deploy/).
99-
100-
Shaarli provides configuration file for Docker Compose, that will setup a Shaarli instance, a [Træfik](https://traefik.io/traefik/) instance (reverse proxy) with [Let's Encrypt](https://letsencrypt.org/) certificates, a Docker network, and volumes for Shaarli data and Træfik TLS configuration and certificates.
101-
102-
Download docker-compose from the [release page](https://docs.docker.com/compose/install/):
103-
104-
```bash
105-
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
106-
$ sudo chmod +x /usr/local/bin/docker-compose
107-
```
82+
Shaarli provides a `docker-compose.yml` file which can be used to run a persistent/autostarted shaarli service using [Docker Compose](https://docs.docker.com/compose/) or in a [Docker stack](https://docs.docker.com/engine/reference/commandline/stack_deploy/). It sets up a Shaarli instance, a [Træfik](https://traefik.io/traefik/) reverse proxy instance with [Let's Encrypt](https://letsencrypt.org/) certificates, a Docker network, and volumes for Shaarli data and Træfik TLS configuration and certificates.
10883

109-
To run Shaarli container and its reverse proxy, you can execute the following commands:
84+
* Download docker-compose from the [release page](https://docs.docker.com/compose/install/).
85+
* Run the following commands to start Shaarli and its reverse proxy:
11086

11187
```bash
112-
# create a new directory to store the configuration:
113-
$ mkdir shaarli && cd shaarli
114-
# Download the latest version of Shaarli's docker-compose.yml
88+
# create a new directory to store your configuration and data
89+
$ sudo mkdir /opt/shaarli
90+
$ sudo mkdir /opt/shaarli/data
91+
$ cd /opt/shaarli
92+
# download the latest version of Shaarli's docker-compose.yml
11593
$ curl -L https://raw.githubusercontent.com/shaarli/Shaarli/latest/docker-compose.yml -o docker-compose.yml
116-
# Create the .env file and fill in your VPS and domain information
94+
# create the .env file and fill in your VPS and domain information
11795
# (replace <shaarli.mydomain.org>, <[email protected]> and <latest> with your actual information)
118-
$ echo 'SHAARLI_VIRTUAL_HOST=shaarli.mydomain.org' > .env
119-
$ echo 'SHAARLI_LETSENCRYPT_EMAIL=admin@mydomain.org' >> .env
120-
# Available Docker tags can be found at https://github.com/shaarli/Shaarli/pkgs/container/shaarli/versions?filters%5Bversion_type%5D=tagged
121-
$ echo 'SHAARLI_DOCKER_TAG=latest' >> .env
122-
# Pull the Docker images
96+
# available Docker tags can be found at https://github.com/shaarli/Shaarli/pkgs/container/shaarli/versions?filters%5Bversion_type%5D=tagged
97+
$ echo 'SHAARLI_VIRTUAL_HOST=shaarli.mydomain.org' | sudo tee .env
98+
$ echo '[email protected]' | sudo tee -a .env
99+
$ echo 'SHAARLI_DOCKER_TAG=latest' | sudo tee -a .env
100+
# pull the required images
123101
$ docker-compose pull
124-
# Run!
102+
# run!
125103
$ docker-compose up -d
126104
```
127105

128-
After a few seconds, you should be able to access your Shaarli instance at [https://shaarli.mydomain.org](https://shaarli.mydomain.org) (replace your own domain name).
106+
After a few seconds, you should be able to access your Shaarli instance at [https://shaarli.mydomain.org](https://shaarli.mydomain.org).
107+
129108

130109
## Running dockerized Shaarli as a systemd service
131110

132-
It is possible to start a dockerized Shaarli instance as a systemd service (systemd is the service management tool on several distributions). After installing Docker, use the following steps to run your shaarli container Shaarli to run on system start.
111+
It is possible to start a dockerized Shaarli instance as a systemd service (systemd is the service management tool on several distributions), that will start automatically on system boot:
133112

134113
As root, create `/etc/systemd/system/docker.shaarli.service`:
135114

@@ -139,19 +118,18 @@ Description=Shaarli Bookmark Manager Container
139118
After=docker.service
140119
Requires=docker.service
141120

142-
143121
[Service]
144122
Restart=always
145123

146124
# Put any environment you want in an included file, like $host- or $domainname in this example
147-
EnvironmentFile=/etc/sysconfig/box-environment
125+
EnvironmentFile=/opt/shaarli/environment
148126

149127
# It's just an example..
150128
ExecStart=/usr/bin/docker run \
151129
-p 28010:80 \
152130
--name ${hostname}-shaarli \
153131
--hostname shaarli.${domainname} \
154-
-v /srv/docker-volumes-local/shaarli-data:/var/www/shaarli/data:rw \
132+
-v /opt/shaarli/data:/var/www/shaarli/data:rw \
155133
-v /etc/localtime:/etc/localtime:ro \
156134
ghcr.io/shaarli/shaarli:latest
157135

@@ -162,18 +140,16 @@ WantedBy=multi-user.target
162140
```
163141

164142
```bash
165-
# reload systemd services definitions
143+
# reload systemd service definitions
166144
systemctl daemon-reload
167-
# start the servie and enable it a boot time
145+
# start the service and enable it a boot time
168146
systemctl enable docker.shaarli.service --now
169147
# verify that the service is running
170148
systemctl status docker.*
171149
# inspect system log if needed
172150
journalctl -f
173151
```
174152

175-
176-
177153
## Docker cheatsheet
178154

179155
```bash

doc/md/REST-API.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ var_dump(getInfo($baseUrl, $secret));
8080
[header].[payload].[signature]
8181
```
8282

83-
##### Header
83+
#### Header
8484

8585
Shaarli only allow one hash algorithm, so the header will always be the same:
8686

@@ -97,7 +97,7 @@ Encoded in base64, it gives:
9797
ewogICAgICAgICJ0eXAiOiAiSldUIiwKICAgICAgICAiYWxnIjogIkhTNTEyIgogICAgfQ==
9898
```
9999

100-
##### Payload
100+
#### Payload
101101

102102
Token expiration: To avoid infinite token validity, JWT tokens must include their creation date in UNIX timestamp format (timezone independent - UTC) under the key `iat` (issued at) field ([1](https://datatracker.ietf.org/doc/html/rfc7519)). This token will be valid during **9 minutes**.
103103

@@ -107,7 +107,7 @@ Token expiration: To avoid infinite token validity, JWT tokens must include thei
107107
}
108108
```
109109

110-
##### Signature
110+
#### Signature
111111

112112
The signature authenticates the token validity. It contains the base64 of the header and the body, separated by a dot `.`, hashed in SHA512 with the API secret available in Shaarli administration page.
113113

@@ -119,7 +119,6 @@ $signature = hash_hmac('sha512', $content, $secret);
119119
```
120120

121121

122-
123122
## Troubleshooting
124123

125124
### Debug mode

0 commit comments

Comments
 (0)