Setup Your Development Environment Based on Docker
Docker containers reduce the complexity of creating development environments. By using them, as a developer, you won’t have to care too much about server administration, e.g., MySQL, Redis or Apache, as it is largely handled by container orchestration.
In this guide, you will learn how to setup an ownCloud development environment, using Docker. To be able to do so, you need to follow these steps:
This guide assumes that you already have
docker-compose installed on your computer.
If you do not, download the version for your operating system and install it.
Be aware that the ownCloud git repository contains a very raw version of ownCloud.
It must be enriched with some other apps inside the
With the ownCloud source available, you can create a Docker-based development environment.
To save time, we’ll use ownCloud’s
It is designed to create a very simple production environment, so it requires some modifications.
|See the Docker Compose file reference to learn all about the [docker-compose.yml] file format.|
Download it to the root of the directory where you put the ownCloud source.
After you download it, change the container image that is used within the ownCloud service to
owncloudci/base:latest, as in the example below.
services: owncloud: image: owncloudci/base:latest
Next, the downloaded/cloned ownCloud source folder must be mounted into the container.
To do so, add an entry to the
volumes section, inside the ownCloud service configuration, as in the example below.
services: owncloud: image: owncloud/oc_dev:latest ... volumes: - <owncloud_source_directory>:/var/www/owncloud ... other volumes configuration
With those two changes made, start the Docker environment by running
docker-compose up -d --build.
|This does not install ownCloud, only starts the Docker container.|
If this is your first time either running
With the container running, ownCloud needs to be installed, by running the
make command from inside the container.
To do this, we first need to attach (log in) to the container.
To do that, we need the running container’s name.
You find that by running
docker-compose ps, which will render output similar to that below in the console:
Name Command State Ports ------------------------------------------------------------------------------------------------- oc_dev_docker_oc_dev_1 apache Up 80/tcp
Take note of the value in the
Name column, i.e.,
This string is a combination of three things, separated by underscores:
The directory in which you ran
The name of the container (
The container’s auto-generated number (
To log in to the running container, replace
<container_name> in the command below with the name of the container in the output from
docker-compose exec <container_name> /bin/bash
After logging in, run
When the command completes, test that you can access ownCloud in your browser by opening
You can also use the
This ensures that changes immediately visible, not later, when the respective caches expire.
config/config.php, as in the example below.
<?php $CONFIG = [ 'debug' => true, ... remaining configuration goes here ... ];
Do not enable this for production! This can create security problems and is only meant for debugging and development!