Nextcloud in docker with Nginx, Redis and Traefik 🐋
Traefik is used to automatically obtain/renew a TLS certificate and for redirect http to https
Based on an official example
Replace all change_me with your values
- MYSQL_PASSWORD - nextcloud DB user password
-
MYSQL_ROOT_PASSWORD - root password for MariaDB container
-
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-u", "root", "-pchange_me"]
Repeat MYSQL_ROOT_PASSWORD password. This is a database healthcheck. "-pPass" for example -
- "traefik.frontend.rule=Host:change_me"
Your domain. traefik.frontend.rule=Host:example.com
-
domain = "change_me"
Yes, domain again -
email = "change_me"
Your email
docker network create traefik
docker-compose up
or
docker-compose up -d
By default, your data is stored in ./volumes/data
For example, you have a disk for your data and it is mounted to /mnt/storage
Replace with
- ./volumes/data:/data
to
- /mnt/storage:/data
ERROR: Network traefik declared as external, but could not be found. Please create the network manually using docker network create traefik
and try again.
Just do what he asks
docker network create traefik
time="2019-08-17T10:46:43Z" level=error msg="Failed to read new account, ACME data conversion is not available : permissions 755 for acme.json are too open, please use 600"
rm -rf traefik/config/acme.json
touch traefik/config/acme.json
chmod 600 traefik/config/acme.json
sudo -u www-data php /var/www/html/nextcloud/occ maintenance:mode --on
sudo mysqldump --single-transaction -u nextcloud -p nextcloud > ~/nextcloud-dump.sql
docker exec -it nextcloud-docker_db_1 mysql -h localhost -u root -pPass -e "DROP DATABASE nextcloud"
docker exec -it nextcloud-docker_db_1 mysql -h localhost -u root -pPass -e "CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"
cat ~/nextcloud-dump.sql | docker exec -i nextcloud-docker_db_1 mysql -u root -pPass nextcloud
docker-compose down
docker-compose up -d
At the moment, docker-compose does not allow to set permissions on a directory. When volume mounted, the directory inside the container gets root rights. For correct work are needed www-data user rights.
docker exec -u www-data -it nextcloud-docker_app_1 php occ maintenance:mode --on
docker exec -it nextcloud-docker_db_1 mysqladmin ping -u root -p123