Docker support

Running SafetyCulture Exporter in Docker

Containerized SafetyCulture Exporter (CLI tool) on alpine to enhance SafetyCulture data exporting from different environments.

This page explains how to consume the SafetyCulture Exporter Image.

Before you begin

Please note that you must have docker installed on your host machine and have admin privileges.

We recommend that you have some basic knowledge of running containers, the use of volumes, and environment variables in docker.

  • Docker must be installed (Docker version 20.10) and running.
    MacOs/Linux users If you’re running macOS/Linux, you need access to CLI interface to run the commands such as terminal.
Windows users If you’re running windows, We recommend using PowerShell on Windows as the commands supports PowerShell.

Ready to get started?

  1. Pull the SafetyCulture Exporter Docker Image for the GitHub Container registry.
$ docker pull
  1. After downloading the image, you can check if the image is available for use.
$ docker images

docker image listing

  1. To share data between the container and the host machine, we need to bind folders on the host to volumes on the container.
    We will create two sub-folder export and config for the container to store all the export files and configuration files.
$ mkdir export && mkdir config

folder structure

  • The config folder will house the safetyculture-exporter.yaml, the file used to configure SafetyCulture Exporter.

  • The export folder will contain export results from the container.

SafetyCulture Exporter relies on configuration files to determine what and where to export data and from which account's perspective.


  1. The following command will create a new container based on the SafetyCulture Exporter image downloaded above.
$ docker run -it \
    --name safetyculture-exporter-docker \
    --mount type=bind,source="$(pwd)"/config,target=/config \ \
    configure \
      --config-path /config/safetyculture-exporter.yaml

alt text

In the step 4 command,
--name we are assigning a name to the container, --mount we attach a file system mount to the container binding the host source="$(pwd)"/config to the container target=/config describes the image to be used for the container. configure SafetyCulture Exporter to get the configuration file and --config-path /config/safetyculture-exporter.yaml specifies the path to the configuration file.

After running this command, locate the 'safetyculture-exporter.yaml' file in the "$(pwd)"/config on the host machine and configure as desired. To learn more about the configuration file, check out Configure SafetyCulture Exporter

Export to CSV

  1. Run the image with the following command to export data to CSV
$ docker run -it \
    --name safetyculture-exporter-docker \
    --mount type=bind,source="$(pwd)"/config,target=/config \
    --mount type=bind,source="$(pwd)"/export,target=/export \ \
    csv \
      --config-path /config/safetyculture-exporter.yaml

In this command, we attach two file system mounts to the container, binding the host

  • The path to the config file source="$(pwd)"/config, target=/config

  • The path to the export folder source="$(pwd)"/export, target=/export

Locate the export data in the specified folder "$(pwd)"/export. If you encounter an error when running SafetyCulture Exporter, you may be able to refer to the error code and message to resolve the error yourself.

Export to Database (Postgres)

For this step, we are connecting the SafetyCulture Exporter container to our database container(Postgres) on the same host. To connect both containers, We will need to get the database container's IP address on our host.

$ docker inspect postgresdb -f "{{json .NetworkSettings.Networks }}"

alt text

In this command, docker inspect returns information of Docker objects, in this case, the ‘postgresdb’ instance’s IP Address. The -f parameter format the output display on the network settings.

Update safetyculture-exporter.yaml file with the database connection string as shown below.

  connection_string: "postgresql://<user>:<password>@"
  dialect: postgres

Run the image with the following command to export data to the Postgres database

$ docker run -it \
  --name safetyculture-exporter-docker \
  --mount type=bind,source="$(pwd)"/config,target=/config \ \
  sql \
    --config-path /config/safetyculture-exporter.yaml

Alternatively, you can also run exports by supplying the database dialect and connection string flags. Learn more

$ docker run -it \
  --name safetyculture-exporter-docker \
  --mount type=bind,source="$(pwd)"/config,target=/config \ \
  sql --db-dialect postgres --db-connection-string postgresql://<user>:<password>@ \
    --config-path /config/safetyculture-exporter.yaml