When we crafted the Nuxeo Docker image, we took care to make it easily configurable through environment variables. Unfortunately, this is often not sufficient and you may want to build your own image to add your own templates and marketplace packages.

There is another better solution that takes advantage of Docker data container and the --volumes-from command line option.

How It Works

In the Nuxeo official docker image, there is a /docker-entrypoint-initnuxeo.d/ folder in which any .sh file that your drop will be executed. Instead of building our own Docker image, we will mount that volume from another configuration image. This image will be run as a data-container, which means that it will run, then stop and allow its volumes to be used by another container.

The Data Container

This container will just have a volume at /docker-entrypoint-initnuxeo.d/, which will contain a shell script and additional data.

FROM busybox ADD marketplace-graphql/marketplace/target/marketplace-nuxeo-graphql-*.zip /docker-entrypoint-initnuxeo.d/ ADD docker /docker-entrypoint-initnuxeo.d/ VOLUME /docker-entrypoint-initnuxeo.d/ RUN /bin/true 

As you can see the container will exit directly after being started.

The source docker folder will contain a setup.sh script that will be executed on container startup. The following installs a Nuxeo package that is also contained in the data container:

#!/bin/bash ​ set +e ​ gosu $NUXEO_USER $NUXEO_HOME/bin/nuxeoctl mp-list|grep nuxeo-graphql > /dev/null 2>&1 if [ $? -eq 1 ]; then gosu $NUXEO_USER $NUXEO_HOME/bin/nuxeoctl mp-install /docker-entrypoint-initnuxeo.d/marketplace-nuxeo-graphql-*.zip --relax=false --accept=true fi set -e 

You can also use that script to copy a new template, or do various things in the container.

To build that container, just launch the command:

docker build -t nuxeo/graphql-conf . 

Use the Data Container

To use the data container and link it to the Nuxeo image, we have to do the following:

docker run --name graphql-conf nuxeo/graphql-conf docker run --rm -it --name nuxeo -p 8080:8080 --volumes-from graphql-conf nuxeo:8.2 

The first line will launch our data container and create its volume. The second line will launch our Nuxeo image and mount the volume from the data container, and then inherit its docker-entrypoint-initnuxeo.d folder. Our setup.sh script will then be executed at startup.

A One-Liner with Docker Compose

Thanks to docker-compose, it’s quite easy to run that in a single command. Just use that compose file:

graphql-conf: build: .

nuxeo-graphql: image: nuxeo:8.2 volumes_from: - graphql-conf ports: - "8080:8080" 

and run docker-compose up


Configuring Nuxeo sometimes needs more than what can be found in the Nuxeo Docker image environment variable. By using a data container, it’s very easy to call a shell script at the container’s startup. Compared to the build my own image solution, the data container solution has several advantages:

  • It is easy to build, so that it can easily fit into you own project (the example here are taken from https://github.com/dmetzler/nuxeo-graphql.
  • It is small (based on busybox), so it’s fast to build.
  • It doesn’t depend on the Nuxeo image. So you can run it with different Nuxeo image versions and you don’t have to rebuild your image when the Nuxeo image changes.