Installing with Docker

Introduction

ownCloud can be installed using Docker, using the official ownCloud Docker image. This official image works standalone for a quick evaluation, but is designed to be used in a docker-compose setup.

Preceding sudo in the docker commands is not necessary, if you add your user to the docker group by invoking

sudo usermod -aG docker <your-user>

Quick Evaluation

sudo docker run -e OWNCLOUD_DOMAIN=localhost:8080 -p8080:8080 owncloud/server

Docker Compose

The configuration:

  • Exposes ports 8080, allowing for HTTP connections.

  • Uses separate MariaDB and Redis containers.

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

The following instructions assume you install locally. For remote access, the value of OWNCLOUD_DOMAIN must be adapted.

  1. Create a new project directory. Then copy and paste the sample docker-compose.yml from this page into that new directory.

  2. 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

ADMIN_USERNAME and ADMIN_PASSWORD will not change between deploys even if you change the values in the .env file. To change them, you’ll need to do docker volume prune, which will delete all your data.

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
sudo 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.6
OWNCLOUD_DOMAIN=localhost:8080
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin
HTTP_PORT=8080
EOF

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

When the process completes, check that all the containers have successfully started, by running sudo 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 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.
To inspect the volumes run:

sudo docker volume ls | grep ownclouddockerserver`

To export the files as a tar archive run:

sudo docker run -v ownclouddockerserver_files:/mnt \
            ubuntu tar cf - -C /mnt . > files.tar

Although the containers are up and running, it may still take a few minutes until ownCloud is fully functional.
To inspect the log output:

sudo docker-compose logs --follow owncloud

Wait until the output shows Starting apache daemon…​ before you access the web UI.

Although all important data persists after:

sudo 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 credentials which you stored in .env earlier. Note that these will not change between deploys even if you change the values in .env.

Stopping the Containers

Assuming you used docker-compose, as in the previous example.
To stop the containers use:

sudo docker-compose stop

To stop and remove containers, along with the related networks, images, and volumes:

sudo docker-compose down --rmi all --volumes

Running occ command

If you want to run an occ command, first go to the directory where your .yaml or .env file is located. Next, you are able to run any command referring to Using the occ Command, by entering:

sudo docker-compose exec owncloud occ <command>

Don’t use the php command prefix, this leads to several errors and is not intended to run in docker environments.

Upgrading ownCloud on Docker

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

  1. Go to your docker directory where your .yaml or .env file exists.

  2. Put ownCloud into maintenance mode. You can do so using the following command:

    sudo docker-compose exec owncloud occ maintenance:mode --on
  3. Create a backup in case something goes wrong during the upgrade process, using the following command:

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

    sudo docker-compose down
  5. 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
  6. View the file to ensure the changes has been implemented.

    cat .env
  7. Start your docker instance again.

    sudo 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:

sudo docker-compose logs --timestamp owncloud

Docker Compose YAML File

Since ownCloud Server 10.5, the dedicated enterprise docker image registry.owncloud.com/owncloud/enterprise is deprecated. All supported enterprise features and apps are now included in the public image owncloud/server available on Docker Hub. A login to our registry registry.owncloud.com is no longer required.

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

Raspberry Pi

If your container fails to start on Raspberry Pi or other ARM devices, you most likely have an old version of libseccomp2 on your host. This should only affect distros based on Rasbian Buster 32 bit. Install a newer version with the following command:

cd /tmp
wget http://ftp.us.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.1-1_armhf.deb
sudo dpkg -i libseccomp2_2.5.1-1_armhf.deb

Alternatively you can add the backports repo for DebianBuster:

sudo apt-key adv --keyserver keyserver.ubuntu.com \
     --recv-keys 04EE7237B7D453EC 648ACFD622F3D138
echo "deb http://deb.debian.org/debian buster-backports main" | \
     sudo tee -a /etc/apt/sources.list.d/buster-backports.list
sudo apt update
sudo apt install -t buster-backports libseccomp2

In any case, you should need to restart the container after confirming you have libseccomp2.4.4 installed.

For more information see: Linux Server Docs