From 02ff7897c0bcb48521ddd0c494f346b6df275ab4 Mon Sep 17 00:00:00 2001 From: "B. van Berkum" Date: Tue, 3 Oct 2017 00:23:34 +0200 Subject: Added docker quickstart example, with user-data volume --- doc/md/index.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'doc') diff --git a/doc/md/index.md b/doc/md/index.md index 24ada6c7..5f10227f 100644 --- a/doc/md/index.md +++ b/doc/md/index.md @@ -22,6 +22,18 @@ It runs the latest development version of Shaarli and is updated/reset daily. Login: `demo`; Password: `demo` +Docker users can start a personal instance from an [autobuild image](https://hub.docker.com/r/shaarli/shaarli/). For an example to start a temporary Shaarli at ``localhost:8000``, and to keeps the data you create (config, storage) during the session: +``` +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 -- cgit v1.2.3 From 22a30602cb31f9b1e36aabae4259561625b7ffe3 Mon Sep 17 00:00:00 2001 From: "B. van Berkum" Date: Tue, 3 Oct 2017 00:24:23 +0200 Subject: Docker 101: container start and cleanup --- doc/md/docker/docker-101.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'doc') diff --git a/doc/md/docker/docker-101.md b/doc/md/docker/docker-101.md index b02dd149..d12a1324 100644 --- a/doc/md/docker/docker-101.md +++ b/doc/md/docker/docker-101.md @@ -60,3 +60,40 @@ wheezy: Pulling from debian Digest: sha256:c584131da2ac1948aa3e66468a4424b6aea2f33acba7cec0b631bdb56254c4fe Status: Downloaded newer image for debian:wheezy ``` + +Docker re-uses layers already downloaded. Iow. if you have only images based on some Alpine or 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``. + +Note that 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. Note that 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 bash +``` +Note the names and ID's of containers are list in ``docker ps``. You an 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``. + +### 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: + +```bash +$ docker rmi -f $(docker images -aq) # remove or mark all images for disposal +$ docker volume rm $(docker volume ls -q) # remove all volumes +``` -- cgit v1.2.3 From 60ed9b8f4142e99114661b5b8a5562aa75bffb48 Mon Sep 17 00:00:00 2001 From: "B. van Berkum" Date: Tue, 3 Oct 2017 00:33:39 +0200 Subject: Typo's, unified structure a bit. - Fixes inevitable typo that crept in. - Removed some blank lines, newlines, to match established whitespace use better. - Minor grammar improvement. --- doc/md/docker/docker-101.md | 12 ++++-------- doc/md/index.md | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'doc') diff --git a/doc/md/docker/docker-101.md b/doc/md/docker/docker-101.md index d12a1324..271dcd5b 100644 --- a/doc/md/docker/docker-101.md +++ b/doc/md/docker/docker-101.md @@ -61,16 +61,14 @@ Digest: sha256:c584131da2ac1948aa3e66468a4424b6aea2f33acba7cec0b631bdb56254c4fe Status: Downloaded newer image for debian:wheezy ``` -Docker re-uses layers already downloaded. Iow. if you have only images based on some Alpine or Ubuntu version for example, those can share disk space. +Docker re-uses layers already downloaded. Iow. if you have images based only 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``. -Note that stopped containers are not destroyed, unless you specify ``--rm``. -To view all created, running and stopped containers, enter: - +Note that stopped containers are not destroyed, unless you specify ``--rm``. To view all created, running and stopped containers, enter: ```bash $ docker ps -a ``` @@ -78,8 +76,7 @@ $ docker ps -a Some containers may be designed or configured to be restarted, others are not. Note that 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: +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 bash ``` @@ -90,8 +87,7 @@ Access can also be through one or more network ports, or disk volumes. Both are ### 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 care only about trying out docker and not about what is running or saved, the following commands should help you out quickly: ```bash $ docker rmi -f $(docker images -aq) # remove or mark all images for disposal diff --git a/doc/md/index.md b/doc/md/index.md index 5f10227f..f83d1702 100644 --- a/doc/md/index.md +++ b/doc/md/index.md @@ -22,7 +22,7 @@ It runs the latest development version of Shaarli and is updated/reset daily. Login: `demo`; Password: `demo` -Docker users can start a personal instance from an [autobuild image](https://hub.docker.com/r/shaarli/shaarli/). For an example to start a temporary Shaarli at ``localhost:8000``, and to keeps the data you create (config, storage) during the session: +Docker users can start a personal instance from an [autobuild image](https://hub.docker.com/r/shaarli/shaarli/). For an example to start a temporary Shaarli at ``localhost:8000``, and keep the data you create (config, storage) during the session: ``` MY_SHAARLI_VOLUME=$(cd /path/to/shaarli/data/ && pwd -P) docker run -ti --rm \ @@ -32,7 +32,6 @@ docker run -ti --rm \ ``` 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 -- cgit v1.2.3 From 62a8b0ff6eafddcd091e3f6676b258f44b5f9e5c Mon Sep 17 00:00:00 2001 From: "B. van Berkum" Date: Tue, 3 Oct 2017 00:57:46 +0200 Subject: Docker-101: added working systemd config example --- doc/md/docker/docker-101.md | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'doc') diff --git a/doc/md/docker/docker-101.md b/doc/md/docker/docker-101.md index 271dcd5b..35a68774 100644 --- a/doc/md/docker/docker-101.md +++ b/doc/md/docker/docker-101.md @@ -84,6 +84,11 @@ Note the names and ID's of containers are list in ``docker ps``. You an even typ 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 +``` + ### 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. @@ -93,3 +98,45 @@ If you care only about trying out docker and not about what is running or saved, $ 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 ubuntu. Once you have a ``docker`` service installed, you can add 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 here, 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 +``` -- cgit v1.2.3 From 2f65b3dd532be9f7a7054095ba3e8fd06be45883 Mon Sep 17 00:00:00 2001 From: "B. van Berkum" Date: Tue, 3 Oct 2017 01:03:27 +0200 Subject: Docker quickstart: one more grammar mistake. Made it a bit more terse. --- doc/md/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/md/index.md b/doc/md/index.md index f83d1702..2b7d0f00 100644 --- a/doc/md/index.md +++ b/doc/md/index.md @@ -22,7 +22,7 @@ It runs the latest development version of Shaarli and is updated/reset daily. Login: `demo`; Password: `demo` -Docker users can start a personal instance from an [autobuild image](https://hub.docker.com/r/shaarli/shaarli/). For an example to start a temporary Shaarli at ``localhost:8000``, and keep the data you create (config, storage) during the session: +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 \ -- cgit v1.2.3 From df8becac4fc810d78917a9896dc72a1f7b336fb9 Mon Sep 17 00:00:00 2001 From: "B. van Berkum" Date: Fri, 6 Oct 2017 00:25:50 +0200 Subject: Minor docker-101 doc updates, typos fixed #983 --- doc/md/docker/docker-101.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'doc') diff --git a/doc/md/docker/docker-101.md b/doc/md/docker/docker-101.md index 35a68774..a9c00b85 100644 --- a/doc/md/docker/docker-101.md +++ b/doc/md/docker/docker-101.md @@ -61,26 +61,26 @@ Digest: sha256:c584131da2ac1948aa3e66468a4424b6aea2f33acba7cec0b631bdb56254c4fe Status: Downloaded newer image for debian:wheezy ``` -Docker re-uses layers already downloaded. Iow. if you have images based only Alpine or some Ubuntu version for example, those can share disk space. +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``. -Note that stopped containers are not destroyed, unless you specify ``--rm``. To view all created, running and stopped containers, enter: +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. Note that both network ports and volumes of a container are created on start, and not editable later. +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 bash ``` -Note the names and ID's of containers are list in ``docker ps``. You an even type only one or two letters of the ID, given they are unique. +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``. @@ -92,15 +92,15 @@ $ docker logs -f ### 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 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 ubuntu. Once you have a ``docker`` service installed, you can add use the following steps to set up Shaarli to run on system start. +### 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 @@ -120,7 +120,7 @@ Requires=docker.service [Service] Restart=always -# Put any environment you want in here, like $host- or $domainname in this example +# 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.. @@ -128,11 +128,9 @@ 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 + shaarli/shaarli:latest ExecStop=/usr/bin/docker rm -f ${hostname}-shaarli -- cgit v1.2.3