Merge pull request #983 from bvberkum/pullrequest/shaarli-docker-quickstart
Docker quickstart
This commit is contained in:
commit
f5bdd8edc8
2 changed files with 89 additions and 0 deletions
|
@ -60,3 +60,81 @@ wheezy: Pulling from debian
|
||||||
Digest: sha256:c584131da2ac1948aa3e66468a4424b6aea2f33acba7cec0b631bdb56254c4fe
|
Digest: sha256:c584131da2ac1948aa3e66468a4424b6aea2f33acba7cec0b631bdb56254c4fe
|
||||||
Status: Downloaded newer image for debian:wheezy
|
Status: Downloaded newer image for debian:wheezy
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Docker re-uses layers already downloaded. In other words if you have images based on Alpine or some Ubuntu version for example, those can share disk space.
|
||||||
|
|
||||||
|
### Start a container
|
||||||
|
A container is an instance created from an image, that can be run and that keeps running until its main process exits. Or until the user stops the container.
|
||||||
|
|
||||||
|
The simplest way to start a container from image is ``docker run``. It also pulls the image for you if it is not locally available. For more advanced use, refer to ``docker create``.
|
||||||
|
|
||||||
|
Stopped containers are not destroyed, unless you specify ``--rm``. To view all created, running and stopped containers, enter:
|
||||||
|
```bash
|
||||||
|
$ docker ps -a
|
||||||
|
```
|
||||||
|
|
||||||
|
Some containers may be designed or configured to be restarted, others are not. Also remember both network ports and volumes of a container are created on start, and not editable later.
|
||||||
|
|
||||||
|
### Access a running container
|
||||||
|
A running container is accessible using ``docker exec``, or ``docker copy``. You can use ``exec`` to start a root shell in the Shaarli container:
|
||||||
|
```bash
|
||||||
|
$ docker exec -ti <container-name-or-id> bash
|
||||||
|
```
|
||||||
|
Note the names and ID's of containers are listed in ``docker ps``. You can even type only one or two letters of the ID, given they are unique.
|
||||||
|
|
||||||
|
Access can also be through one or more network ports, or disk volumes. Both are specified on and fixed on ``docker create`` or ``run``.
|
||||||
|
|
||||||
|
You can view the console output of the main container process too:
|
||||||
|
```bash
|
||||||
|
$ docker logs -f <container-name-or-id>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Docker disk use
|
||||||
|
Trying out different images can fill some gigabytes of disk quickly. Besides images, the docker volumes usually take up most disk space.
|
||||||
|
|
||||||
|
If you care only about trying out docker and not about what is running or saved, the following commands should help you out quickly if you run low on disk space:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ docker rmi -f $(docker images -aq) # remove or mark all images for disposal
|
||||||
|
$ docker volume rm $(docker volume ls -q) # remove all volumes
|
||||||
|
```
|
||||||
|
|
||||||
|
### Systemd config
|
||||||
|
Systemd is the process manager of choice on Debian-based distributions. Once you have a ``docker`` service installed, you can use the following steps to set up Shaarli to run on system start.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
systemctl enable /etc/systemd/system/docker.shaarli.service
|
||||||
|
systemctl start docker.shaarli
|
||||||
|
systemctl status docker.*
|
||||||
|
journalctl -f # inspect system log if needed
|
||||||
|
```
|
||||||
|
|
||||||
|
You will need sudo or a root terminal to perform some or all of the steps above. Here are the contents for the service file:
|
||||||
|
```
|
||||||
|
[Unit]
|
||||||
|
Description=Shaarli Bookmark Manager Container
|
||||||
|
After=docker.service
|
||||||
|
Requires=docker.service
|
||||||
|
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
# Put any environment you want in an included file, like $host- or $domainname in this example
|
||||||
|
EnvironmentFile=/etc/sysconfig/box-environment
|
||||||
|
|
||||||
|
# It's just an example..
|
||||||
|
ExecStart=/usr/bin/docker run \
|
||||||
|
-p 28010:80 \
|
||||||
|
--name ${hostname}-shaarli \
|
||||||
|
--hostname shaarli.${domainname} \
|
||||||
|
-v /srv/docker-volumes-local/shaarli-data:/var/www/shaarli/data:rw \
|
||||||
|
-v /etc/localtime:/etc/localtime:ro \
|
||||||
|
shaarli/shaarli:latest
|
||||||
|
|
||||||
|
ExecStop=/usr/bin/docker rm -f ${hostname}-shaarli
|
||||||
|
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
|
@ -22,6 +22,17 @@ It runs the latest development version of Shaarli and is updated/reset daily.
|
||||||
|
|
||||||
Login: `demo`; Password: `demo`
|
Login: `demo`; Password: `demo`
|
||||||
|
|
||||||
|
Docker users can start a personal instance from an [autobuild image](https://hub.docker.com/r/shaarli/shaarli/). For example to start a temporary Shaarli at ``localhost:8000``, and keep session data (config, storage):
|
||||||
|
```
|
||||||
|
MY_SHAARLI_VOLUME=$(cd /path/to/shaarli/data/ && pwd -P)
|
||||||
|
docker run -ti --rm \
|
||||||
|
-p 8000:80 \
|
||||||
|
-v $MY_SHAARLI_VOLUME:/var/www/shaarli/data \
|
||||||
|
shaarli/shaarli
|
||||||
|
```
|
||||||
|
|
||||||
|
A brief guide on getting starting using docker is given in [Docker 101](docker/docker-101).
|
||||||
|
To learn more about user data and how to keep it across versions, please see [Upgrade and Migration](Upgrade-and-migration) documentation.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue