Run OpenTAXII on Docker
OpenTAXII can also be run using docker. This guide assumes that you have access to a local or remote docker server, and won’t go into the setup of docker.
From the root of this repository, build and run a development image.
docker build -t opentaxii:local .
docker run --pull=never -d -p 9000:9000 opentaxii:local
To have the instance preloaded with example data, see volumes
OpenTAXII is now accessible through port 9000, with data stored locally in a SQLite database.
Configuration
Configuration is done through environment variables.
Common configuration parameters are:
OPENTAXII_DOMAIN: (optional)-
This specifies under which domain the OpenTAXII server is available, default:
localhost:9000
Setting up authentication is done with the following two variables:
OPENTAXII_SECRET: (optional)-
This is the secret with which the generated token is encoded.
If you want to use a PostgreSQL database, instead of the included SQLite database, you can use the following environment variables for configuration:
DATABASE_HOST: (required)-
This is the database host to connect to
DATABASE_PORT: (optional)-
Default is
5432 DATABASE_NAME: (optional)-
The database to use, by default uses
postgres
If you would like to use a different Database for authentication, you can also set the following variables (any variable not set, will use it’s regular DB counterpart):
AUTH_DATABASE_HOST: (required)-
This is the database host to connect to
AUTH_DATABASE_PORT: (optional)-
Default is
5432 AUTH_DATABASE_USER: (optional)-
If not set, the default
postgresis used. AUTH_DATABASE_PASS: (optional)-
If not set, the database can be accessed by all containers on the same host!
AUTH_DATABASE_NAME: (optional)-
The database to use, by default uses
postgres
Volumes
This docker container exposes two volumes, which can be attached to a running instance:
/data-
This volume will contain the SQLite databases used by the default instance.
/input/data-configuration.yml-
If you want to pre-load the running instance with services/collections/accounts, An example is provided with data-configuration.yml.
/input/opentaxii.yml-
To overwrite the default configuration used by the docker instance.
After building opentaxii:local, run this command from the repository root to load the example data.
docker run --pull=never -d -p 9000:9000 -v "$PWD/examples:/input:ro" opentaxii:local
Make sure your naming is correct. It will only execute actions when files data-configuration.yml or opentaxii.yml are present.
Extending
To install a custom package and supply an OpenTAXII configuration file, use the locally built opentaxii:local image as the base for a Dockerfile.
FROM opentaxii:local
RUN pip install custom-package
COPY opentaxii.yml /input/opentaxii.yml
Build the custom image from the directory containing this Dockerfile and your opentaxii.yml.
docker build -t opentaxii:custom .
TAXII 2 instance with Compose
The TAXII 2 Compose example in examples/docker-compose-taxii2.yml builds OpenTAXII from this checkout. Run these commands from the repository root.
# Start
docker compose -f examples/docker-compose-taxii2.yml up --build
# To add dummy data, run this while the compose project is running
docker compose -f examples/docker-compose-taxii2.yml exec -T opentaxii bash < examples/taxii2/data-setup.sh
Full Example with Compose
The full Compose example in examples/docker-compose.yml builds OpenTAXII from this checkout and starts two OpenTAXII instances backed by PostgreSQL. It preloads the services, collections, and accounts from examples/data-configuration.yml.
Run this command from the repository root.
docker compose -f examples/docker-compose.yml up --build
Next steps
Continue to Configuration page to learn how to configure OpenTAXII.