Installing with Docker

ownCloud can be installed using Docker, using the official ownCloud Docker image. This official image works standalone (e.g. for a quick evaluation with docker run -p8080:8080 owncloud/server) but it is designed to work with a data volume in the host filesystem and with separate MariaDB and Redis containers.

The configuration:

  • exposes ports 8080, allowing for HTTP connections.

  • mounts the data and MySQL data directories on the host for persistent storage.

Installation on a Local Machine

To use it, first create a new project directory. Then copy and paste the sample docker-compose.yml from this page into that new directory. Next, create a .env configuration file, which contains the required configuration settings. Only a few settings are required, these are:

Setting Name Description Example

OWNCLOUD_VERSION

The ownCloud version

latest

OWNCLOUD_DOMAIN

The ownCloud domain

localhost:8080

ADMIN_USERNAME

The admin username

admin

ADMIN_PASSWORD

The admin user’s password

admin

HTTP_PORT

The HTTP port to bind to

8080

Then, you can start the container, using your preferred Docker command-line tool. The example below shows how to use Docker Compose.

# Create a new project directory
mkdir owncloud-docker-server

cd owncloud-docker-server

# Copy docker-compose.yml from the GitHub repository
wget https://raw.githubusercontent.com/owncloud/docs/master/modules/admin_manual/examples/installation/docker/docker-compose.yml

# Create the environment configuration file
cat << EOF > .env
OWNCLOUD_VERSION=10.5
OWNCLOUD_DOMAIN=localhost:8080
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin
HTTP_PORT=8080
EOF

# Build and start the container
docker-compose up -d

When the process completes, then check that all the containers have successfully started, by running docker-compose ps. If they are all working correctly, you should expect to see output similar to that below:

Name                              Command                     State   Ports
__________________________________________________________________________________________
ownclouddockerserver_db_1         … /bin/s6-svscan /etc/s6    Up      3306/tcp
ownclouddockerserver_owncloud_1   … /usr/bin/owncloud server  Up      0.0.0.0:8080->8080/tcp
ownclouddockerserver_redis_1      … /bin/s6-svscan /etc/s6    Up      6379/tcp

In it, you can see that the database, ownCloud, and Redis containers are running, and that only ownCloud is accessible via port 8080 on the host machine.

All files stored in this setup are contained in Docker volumes, rather than a physical filesystem tree. It is the admin’s responsibility to persist the files. Use, e.g., docker volume ls | grep ownclouddockerserver to inspect the volumes. Use e.g., docker run -v ownclouddockerserver_files:/mnt ubuntu tar cf - -C /mnt . > files.tar to export the files as a tar archive.

Although the containers are up and running, it may still take a few minutes until ownCloud is fully functional. Run, e.g., docker-compose logs --follow owncloud and inspect the log output. Wait until the output shows "Starting apache daemon…​" before you access the web UI.

Although all important data persists after docker-compose down; docker-compose up -d, there are certain details that get lost, e.g., default apps may re-appear after they were uninstalled.

Logging In

To log in to the ownCloud UI, open http://localhost:8080 in your browser of choice, where you see the standard ownCloud login screen, as in the image below.

The ownCloud UI via Docker

The username and password are the admin username and password which you stored in .env earlier.

Stopping the Containers

Assuming you used docker-compose, as in the previous example, to stop the containers use docker-compose stop. Alternatively, use docker-compose down --rmi all --volumes to stop and remove containers, along with the related networks, images, and volumes.

Upgrading ownCloud on Docker

When a new version of ownCloud gets released, you should update your instance. To do so, follow these simple steps.

First, go to your docker directory where your .yaml or .env file exists. Second, put ownCloud into maintenance mode; you can do so using the following command:

docker-compose exec owncloud occ maintenance:mode --on

Third, create a backup in case something goes wrong during the upgrade process, using the following command:

docker-compose exec db backup
This assumes that you are using the default database container from Webhippie.

Fifth, shutdown the containers.

docker-compose down

Sixth, update the version number of ownCloud in your .env file or the YAML file. You can use sed for it, as in the following example.

# Make sure that you adjust the example to match your installation.
sed -i 's/^OWNCLOUD_VERSION=.*$/OWNCLOUD_VERSION=<newVersion>/' /compose/*/.env

Seventh, view the file to ensure the changes has been implemented.

cat .env

Eighth, start your docker instance again.

docker-compose up -d

Now you should have the current ownCloud running with docker-compose. Please note that the container will automatically run occ upgrade when starting up. If you notice the container starting over and over again, you can check the update log with the following command:

docker-compose logs --timestamp owncloud

Docker Compose YAML File

If you are an enterprise customer and are already registered on portal.owncloud.com, replace image: owncloud/server with image: registry.owncloud.com/owncloud/enterprise to be able to download our enterprise docker image. Then, login to our registry by running docker login registry.owncloud.com, along with your portal credentials.
version: '2.1'

volumes:
  files:
    driver: local
  mysql:
    driver: local
  backup:
    driver: local
  redis:
    driver: local

services:
  owncloud:
    image: owncloud/server:${OWNCLOUD_VERSION}
    restart: always
    ports:
      - ${HTTP_PORT}:8080
    depends_on:
      - db
      - redis
    environment:
      - OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN}
      - OWNCLOUD_DB_TYPE=mysql
      - OWNCLOUD_DB_NAME=owncloud
      - OWNCLOUD_DB_USERNAME=owncloud
      - OWNCLOUD_DB_PASSWORD=owncloud
      - OWNCLOUD_DB_HOST=db
      - OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME}
      - OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - OWNCLOUD_MYSQL_UTF8MB4=true
      - OWNCLOUD_REDIS_ENABLED=true
      - OWNCLOUD_REDIS_HOST=redis
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - files:/mnt/data

  db:
    image: webhippie/mariadb:latest
    restart: always
    environment:
      - MARIADB_ROOT_PASSWORD=owncloud
      - MARIADB_USERNAME=owncloud
      - MARIADB_PASSWORD=owncloud
      - MARIADB_DATABASE=owncloud
      - MARIADB_MAX_ALLOWED_PACKET=128M
      - MARIADB_INNODB_LOG_FILE_SIZE=64M
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - mysql:/var/lib/mysql
      - backup:/var/lib/backup

  redis:
    image: webhippie/redis:latest
    restart: always
    environment:
      - REDIS_DATABASES=1
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - redis:/var/lib/redis

Troubleshooting

If you have issues logging in to the registry, make sure the .docker file is in your home directory. If you installed Docker via snap, create a symbolic link to your home directory with the following command:

ln -sf snap/docker/384/.docker

The version 384 might differ from yours. Please adjust it accordingly.