The guide is outdated! Please visit the [official github] (GitHub - nextcloud/docker: ā“ Docker image of Nextcloud) for up-to-date infos and help.
Hello,
Iām playing around with docker containers and created a docker-compose file for a full nextcloud installation including
- Nginx reverse proxy
- Automated creation and renew of letsencrypt ssl certificates
- Nextcloud container,
- mariaDB
I used the following images:
- [nginx] (Docker)
- jwilder/docker-gen
- jrcs/letsencrypt-nginx-proxy-companion
- wonderfall/nextcloud
- mariadb
I thought someone could use it so I share it here.
Since the nextcloud docker container is not official and has some bugs / incompatibilities, I would not recommend using it in a production environment or even at home at this point!
There are some people working on an official nextcloud container, see here and on GitHub, but nothing is ready yet.
docker-compose.yml
version: ā2ā
services:
proxy
nginx:
image: nginx
container_name: nginx
ports:
- 80:80
- 443:443
volumes:
- ./proxy/conf.d:/etc/nginx/conf.d
- ./proxy/vhost.d:/etc/nginx/vhost.d
- ./proxy/html:/usr/share/nginx/html
- ./proxy/certs:/etc/nginx/certs:ro
networks:
- proxy-tier
#proxy-file-generator
nginx-gen:
image: jwilder/docker-gen
container_name: nginx-gen
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./proxy/templates/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
volumes_from:
- nginx
entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -only-exposed -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
letsencrypt
letsencrypt-nginx-proxy-companion:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: letsencrypt-companion
depends_on: [nginx-gen]
volumes_from:
- nginx
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./proxy/certs:/etc/nginx/certs:rw
environment:
- NGINX_DOCKER_GEN_CONTAINER=nginx-gen
#app
nextcloud:
image: wonderfall/nextcloud
container_name: nextcloud
links:
- db_nextcloud:db_nextcloud
environment:
- UID=1000
- GID=1000
volumes:
- ./nextcloud/data:/data
- ./nextcloud/config:/config
- ./nextcloud/apps:/apps2
environment:
- VIRTUAL_HOST=domain_name
- VIRTUAL_NETWORK=nginx-proxy
- VIRTUAL_PORT=80
- LETSENCRYPT_HOST=domain_name
- LETSENCRYPT_EMAIL=certificate_mail_address
networks:
- proxy-tier
depends_on:
- letsencrypt-nginx-proxy-companion
db_nextcloud: database
image: mariadb:10
container_name: db_nextcloud
volumes:
- ./nextcloud/db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root_password
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_PASSWORD=database_password
networks:
- proxy-tier
depends_on:
- letsencrypt-nginx-proxy-companion
networks:
proxy-tier:
external:
name: nginx-proxy
Preparation:
Before runnig docker-compose there are three things that need to be done.
- Create a virtual network called nginx-proxy (source)
docker network create -d bridge nginx-proxy
- Download the nginx proxy template file
mkdir ./proxy/templates -p
curl https://raw.githubusercontent.com/jwilder/nginx-proxy/master/nginx.tmpl > ./proxy/templates/nginx.tmpl
- Replace the bold strings in the docker-compose file. (You might want to replace the path volume directories on the host from
./___
to absolute paths. Consider this in step 2)
Running:
To run the hole configuration simply type
docker-compose up -d
The letsencrypt container may take a few moments to create the certificates but all this is handled automatically.
You can now access your nextcloud installation from your domain and the configuration page shows up. Use the password you chose in the docker-compose file and for server the database container name (db_nextcloud in this case). Additional configuration is described here.
For now there might be a little bug that letās the configuration page show up again everytime the container is restartet. Simply adding the following lines manually into the nextcloud config.php solves this issue.
āinstalledā => ātrueā,
Updates
Updates for any container are als simple as using docker-compose pull
and docker-compose up -d
again.
Have Fun with your containers ;),
Snowyo