Who created the Docker logo

Multi container support for Docker apps for Univention App Center

Multi container with Docker Compose

Docker Compose, which is also used in the App Center, is used for multi-container applications in the Docker environment. The central element is the docker-compose.yml file. The following is an example of the Rocket.Chat app:

version: '2' services: rocketchat: image: rocketchat / rocket.chat: latest restart: unless-stopped volumes: - ./uploads:/app/uploads environment: - PORT = 3000 - ROOT_URL = http: // localhost: 3000 - MONGO_URL = mongodb: // mongo: 27017 / rocketchat - MONGO_OPLOG_URL = mongodb: // mongo: 27017 / local - MAIL_URL = smtp: //smtp.email depends_on: - mongo ports: - 3000: 3000 mongo: image: mongo: 3.2 restart: unless-stopped volumes: - ./data/db:/data/db command: mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine = mmapv1 # this container's job is just run the command to initialize the replica set. # it will run the command and remove himself (it will not stay running) mongo-init-replica: image: mongo: 3.2 command: 'mongo mongo / rocketchat --eval "rs.initiate ({_id:' 'rs0' ' , members: [{_id: 0, host: '' localhost: 27017 ''}]}) "'depends_on: - mongo hubot: image: rocketchat / hubot-rocketchat: latest restart: unless-stopped environment: - ROCKETCHAT_URL = rocketchat : 3000 - ROCKETCHAT_ROOM = GENERAL - ROCKETCHAT_USER = bot - ROCKETCHAT_PASSWORD = botpassword - BOT_NAME = bot - EXTERNAL_SCRIPTS = hubot-help, hubot-seen, hubot-links, hubot-diagnostics depends_on: - rocketchat volumes: - ./scripts:/home/ hubot / scripts ports: - 3001: 8080

These files in YAML format define various services. These services indicate which Docker image should be used and which environment variables, volumes, ports and dependencies on other containers are required. In its entirety, an application is described with all its parts that are started using Docker Compose.

Docker Compose configuration using the example of the Zammad application

App providers can store their Docker Compose configuration in the App Provider Portal, as the screenshot shows using Zammad as an example.

App providers can store a whole range of configuration settings for the app in the provider portal. This also includes scripts that are executed at different phases during the app lifecycle in the container and on the host.

In the case of multi-container apps, it must be specified for the App Center which of the defined services or which container is the main service to which these scripts and also some configurations are to be applied. As a rule, the main service is the container that contains the application.

Possible changes to the Docker Compose file through the App Center

Before a multi-container app can be put into operation on the user's target system via Docker Compose, the docker-compose.yml is processed directly by the App Center on the UCS system and a few points are changed or supplemented.

  1. The App Center adds two standard volumes for the main service, as they are also integrated in single container apps. These are the directories and on the UCS host. If volumes are also defined in the App Configuration in the App Provider Portal, these are also supplemented in the Docker Compose file by the App Center for the main service.
  2. If ports are defined in the App Provider Portal, these are also added to the Docker Compose file. Ports that have already been defined continue to exist. If the same port is defined in the portal and in the Docker Compose file, the configuration in the App Provider Portal has priority. For example, if the Docker Compose file says that port 4500 is made available externally as port 4500, but it is defined in the portal that this port is to be used as 6500, the Docker Compose file is adapted so that port 4500 is set to 6500 is mapped on the host.
  3. Another special feature is the specification of the web interface. If the Docker Compose file says that port 80 or 443 should be opened to the outside world and it is specified in the app configuration that these ports should be used by the App Center for the web interface, the App Center will be opened on the target system on the fly define a port and specify it in the Docker Compose file. The reason for this is that UCS hosts usually occupy ports 80 and 443 with a web server. The App Center creates an Apache Reverse Proxy configuration so that the app can be reached via a URL in the form https: //hostname.domain/appid/.
  4. Docker containers like to use environment variables. Docker apps on UCS also make use of this and UCS supplies a number of environment variables via the App Center, such as: B. Parameters for an LDAP connection. The i.a. The variables required for this are also written to the Docker Compose file.
  5. Furthermore, in the main service as well as in single container apps, all UCR variables defined on UCS are available under, as well as the password for the so-called machine account under, via which the main service has authenticated, read access to the LDAP directory.
  6. When a multi-container app is published, the Docker Compose file is adapted on the server side and the information on the Docker image is changed so that it refers to the Docker images in the Univention Docker registry. All Docker images of published apps are copied into the Univention Docker registry in order to be independent of Docker's own infrastructure. This is the only server-side change to the Docker Compose file.

As a result, Docker Compose starts a Docker Compose configuration on the target system that no longer corresponds 100% to the input of the app provider. This is necessary because a large amount of information must be available for optimal integration when an app is started. In this way, the apps can optimally adapt to the local environment and are preconfigured accordingly so that users can get started right away. The modified Docker Compose file can be found on the UCS target system under
.

App providers can now start creating their Docker apps in the App Provider Portal and save the Docker Compose configuration. The documentation for this will appear in the next few days. The first multi-container apps are already on their way and should be published in the App Center in the next few weeks.