Skip to content

Commit

Permalink
docker-compose: Switch to docker managed volumes.
Browse files Browse the repository at this point in the history
Docker-managed volumes[^1] are more cross-platform compatible than
hard-coded paths, and will work even if the Docker user cannot write
to the arbitrary path of `/opt/docker/zulip` on the Docker host.

[^1]: https://docs.docker.com/storage/volumes/

Co-authored-by: Alex Vandiver <alexmv@zulip.com>
  • Loading branch information
adarshpk and alexmv committed Nov 29, 2022
1 parent 24678b6 commit 74aea02
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 30 deletions.
33 changes: 7 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,33 +55,14 @@ written to the image's filesystem is lost). To handle persistent
state that needs to persist after the Docker equivalent of a reboot or
upgrades (like uploaded files or the Zulip database), container
systems let you configure certain directories inside the container
from the host system's filesystem.

For example, this project's `docker-compose.yml` configuration file
specifies a set of volumes where
[persistent Zulip data][persistent-data] should be stored under
`/opt/docker/zulip/` in the container host's file system:

* `/opt/docker/zulip/postgresql/data/` has the postgres container's
persistent storage (i.e. the database).
* `/opt/docker/zulip/zulip/` has the application server container's
persistent storage, including the secrets file, uploaded files,
etc.

This approach of mounting `/opt/docker` into the container is the
right model if you're hosting your containers from a single host
server, which is how `docker-compose` is intended to be used. If
you're using Kubernetes, Docker Swarm, or another cloud container
service, then these persistent storage volumes are typically
configured to be network block storage volumes (e.g. an Amazon EBS
volume) so that they can be mounted from any server within the
cluster.

What this means is that if you're using `docker-zulip` in production
with `docker-compose`, you'll want to configure your backup system to
do backups on the `/opt/docker/zulip` directory, in order to ensure
you don't lose data.
from the host.

This project's `docker-compose.yml` configuration file uses [Docker managed
volumes][volumes] to store [persistent Zulip data][persistent-data]. If you use
the Docker Compose deployment, you should make sure that Zulip's volumes are
backed up, to ensure that Zulip's data is backed up.

[volumes]: https://docs.docker.com/storage/volumes/
[persistent-data]: https://zulip.readthedocs.io/en/latest/production/maintain-secure-upgrade.html#backups

## Prerequisites
Expand Down
13 changes: 9 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
# the first time on a host. Instructions are available in README.md.
POSTGRES_PASSWORD: "REPLACE_WITH_SECURE_POSTGRES_PASSWORD"
volumes:
- "/opt/docker/zulip/postgresql/data:/var/lib/postgresql/data:rw"
- "postgresql-10:/var/lib/postgresql/data:rw"
memcached:
image: "memcached:alpine"
restart: unless-stopped
Expand All @@ -34,7 +34,7 @@ services:
RABBITMQ_DEFAULT_USER: "zulip"
RABBITMQ_DEFAULT_PASS: "REPLACE_WITH_SECURE_RABBITMQ_PASSWORD"
volumes:
- "/opt/docker/zulip/rabbitmq:/var/lib/rabbitmq:rw"
- "rabbitmq:/var/lib/rabbitmq:rw"
redis:
image: "redis:alpine"
restart: unless-stopped
Expand All @@ -47,7 +47,7 @@ services:
environment:
REDIS_PASSWORD: "REPLACE_WITH_SECURE_REDIS_PASSWORD"
volumes:
- "/opt/docker/zulip/redis:/data:rw"
- "redis:/data:rw"
zulip:
image: "zulip/docker-zulip:5.7-0"
restart: unless-stopped
Expand Down Expand Up @@ -90,8 +90,13 @@ services:
# Uncomment this when configuring the mobile push notifications service
# SETTING_PUSH_NOTIFICATION_BOUNCER_URL: 'https://push.zulipchat.com'
volumes:
- "/opt/docker/zulip/zulip:/data:rw"
- "zulip:/data:rw"
ulimits:
nofile:
soft: 1000000
hard: 1048576
volumes:
zulip:
postgresql-10:
rabbitmq:
redis:

0 comments on commit 74aea02

Please sign in to comment.