Deploying OwnCloud with Docker
Deploying OwnCloud with Docker
Installing OwnCloud directly on Ubuntu 18 can be challenging due to dependency conflicts and database configuration issues. After struggling with a manual installation, I discovered that the Dockerized version of OwnCloud is much easier to set up and maintain.
Here is my installation and configuration log.
Prerequisites
Docker Compose Configuration
I referenced the official OwnCloud Docker installation guide and the official example to create a customized docker-compose.yml.
Customizations:
- External Database: I removed the database container dependencies because I wanted to connect to an existing AWS RDS instance.
- External Storage: I configured volumes to mount my existing NAS storage.
- Redis Removed: Since this instance serves very few users and I wanted to minimize CPU usage on the VM, I removed the Redis service.
Here is the docker-compose.yml file:
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
version: '2.1'
services:
owncloud:
image: owncloud/server:10.0
restart: always
ports:
- 8080:8080
environment:
- OWNCLOUD_DOMAIN=localhost
- OWNCLOUD_DB_TYPE=mysql
- OWNCLOUD_DB_NAME=db_name
- OWNCLOUD_DB_USERNAME=db_username
- OWNCLOUD_DB_PASSWORD=db_password
# db can be any remote url with accessing privilege
- OWNCLOUD_DB_HOST=db_url
- OWNCLOUD_ADMIN_USERNAME=admin
- OWNCLOUD_ADMIN_PASSWORD=admin
# for owncloud >= 9.0, add this config to allow local directory as external storage
- OWNCLOUD_ALLOW_EXTERNAL_LOCAL_STORAGE=true
healthcheck:
test: ["CMD", "/usr/bin/healthcheck"]
interval: 30s
timeout: 10s
retries: 5
volumes:
- /mnt/data/owncloud:/mnt/data
- /other-directory1:/mnt/data/d1
- /other-directory2:/mnt/data/d2
Running OwnCloud
- Start the service:
1
sudo docker-compose up -d
- Access OwnCloud at
http://server_ip:8080. - Note: Ensure port
8080is open in your VM’s firewall/security group settings.
Adding Local Storage
To add local directories as external storage, verify that OWNCLOUD_ALLOW_EXTERNAL_LOCAL_STORAGE=true is set, and refer to the Local Storage Configuration documentation.
Useful Commands
- Scan files manually copied to the data directory:
1
docker-compose exec owncloud occ files:scan --all
This post is licensed under CC BY 4.0 by the author.