Creating A New Docker Image
Creating a Docker Image
OpenBoxes release images are automatically published to GitHub packages whenever a commit is tagged for release (see the workflow file for details). No manual work required.
However, if you ever need to manually create a Docker image for the application, you can do so by following these instructions:
Prerequisites
Install Docker (20.04+)
Clone the openboxes repository
Set up an openboxes database with a valid db user
Steps
Start Docker
Navigate to the root directory of the openboxes repository
Run
./gradlew prepareDocker -Dgrails.env=prodThis produces an executable
openboxes.warfile, then copies it and its configuration files to the/build/dockerdirectory. Note that the generated WAR file contains an embedded Tomcat servlet.
Run
docker build --tag="openboxes/openboxes:latest" build/docker/This will take in the WAR file and build a Docker image for the app.
Running Docker Images
Once you have a Docker image (whether it's an official release or one you created yourself) you can use it to start up a containerized version of OpenBoxes.
We assume that you have already configured your database server by this point.
If running an official release image, run the following:
docker run -p 8080:8080 --name=openboxes ghcr.io/openboxes/openboxes:latestIf you need a specific version, you can replace
latestwith that version (such asv0.9.5)
If running a manually created image, run the following:
docker run -p 8080:8080 --name=openboxes openboxes/openboxes:latest
Then navigate to http://localhost:8080/openboxes to access your server.
Overriding Environment Variables
When running the application locally, the default environment variables are likely adequate, but if you need to customize them for your specific setup, you can do so via a .env file.
Create a
docker/.envfile (see the .env.example file for reference)Add the
--env-fileparameter to your docker run commandFor example:
docker run --env-file=docker/.env -p 8080:8080 --name=openboxes openboxes/openboxes:latest
Alternatively, you can directly provide environment variables via the --env parameter.
For example: docker run -p 8080:8080 --name=openboxes --env DATASOURCE_USERNAME='openboxes' --env=DATASOURCE_PASSWORD='openboxes' openboxes/openboxes:latest
Persistable Logs (journald)
If you'd like the application logs to be persisted after the container has been stopped/removed, run the docker container with journald agent.
For example: docker run --env-file=docker/.env -p 8080:8080 --name=openboxes --log-driver=journald openboxes/openboxes:latest
The logs will then be able to be accessed with: journalctl -u docker CONTAINER_NAME=openboxes
Running against a database server on the host machine
You can connect a containerized OpenBoxes instance to a SQL server that is running on the host by using the host.docker.internal keyword in the JDBC url.
To achieve this, override the DATASOURCE_URL environment variable and add the host gateway via the --add-host parameter.
For example: docker run -p 8080:8080 --name=openboxes --env DATASOURCE_URL='jdbc:mysql://host.docker.internal:3306/openboxes?useSSL=false' --add-host host.docker.internal:host-gateway openboxes/openboxes:latest
You will also need to set bind.address=0.0.0.0 in your SQL configuration.
Last updated
Was this helpful?

