Deploy NextCloud with Docker and Traefik

I still remember how excited I was when I first learnt I could deploy services so easily with Docker and Traefik. At the time I was experimenting a lot of different dockerized images like crazy and I settles with 3 major services. I had already written article about WordPress and Bitwarden today it is time to introduce the last one - NextCloud.

As you are reading this article right now, I assume you should at least know what NextCloud is. Basically it is a Dropbox (for storage) + Office (for editing documents) on your own server.

Anyway, let me put down my docker-compose.yml file first.

Please note, my docker-compose.yml is meant to be used with my Traefik configurations. It might not work with your set ups. You can find my Traefik configuration at this link

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
version: '3.7'

services:
db:
image: mariadb:latest
container_name: nextcloud-db
volumes:
- nextcloud-db-data:/var/lib/mysql
networks:
- default
restart: always
environment:
TZ: UTC
MYSQL_ROOT_PASSWORD: supersecretpassword
MYSQL_DATABASE: db
MYSQL_USER: dbuser
MYSQL_PASSWORD: dbpassword

redis:
image: redis:latest
restart: always
networks:
- default
volumes:
- redis:/var/lib/redis

nextcloud:
depends_on:
- redis
- db
image: nextcloud:stable
container_name: nextcloud
volumes:
- ./files:/var/www/html
networks:
- proxy
- default
restart: always
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy"
- "traefik.http.routers.nextcloud-secure.entrypoints=websecure"
- "traefik.http.routers.nextcloud-secure.rule=Host(`cloud.yourdomain`)"
- "traefik.http.routers.nextcloud-secure.service=nextcloud-service"
- "traefik.http.services.nextcloud-service.loadbalancer.server.port=80"
environment:
REDIS_HOST: redis
MYSQL_HOST: db:3306
MYSQL_DATABASE: db
MYSQL_USER: dbuser
MYSQL_PASSWORD: dbpassword

networks:
proxy:
external: true

volumes:
nextcloud-db-data:
name: nextcloud-db-data
redis:
name: nextcloud-redis

As you can see, there are not too many differences between this configure than my WordPress config. I only added a Redis service to speed up the website and change the image tag from latest to stable. In my opinion, stability is the most important aspect of online storage. If you want to know more about what each part does, please check my WordPress post.

Thank you for reading, see you next time.