Skip to content

Docker

There are a few ways to use the CSV importer and Docker. There are some gotchas when it comes to Docker and IP addresses, so please check out the instructions at the bottom of the page.

The CSV import uses the Firefly III API. Read more about the API in the Firefly III documentation.

Warning

You should really read the configuration page first!

Web server with personal access token

Use the following run command to launch the CSV importer.

docker run \
--rm \
-e FIREFLY_III_ACCESS_TOKEN= \
-e FIREFLY_III_URL= \
-p 8081:8080 \
fireflyiii/csv-importer:latest

By running this script, you will start a web server on port 8081 that will allow you to import data. You should append the command with your Personal Access Token and Firefly III URL. You should really read the configuration page on how to get these values.

Web server with a client ID

Use the following run command to launch the CSV importer.

docker run \
--rm \
-e FIREFLY_III_CLIENT_ID= \
-e FIREFLY_III_URL= \
-p 8081:8080 \
fireflyiii/csv-importer:latest

By running this script, you will start a web server on port 8081 that will allow you to import data. Append the command with your Client ID and Firefly III URL. You should really read the configuration page on how to get these values.

Web server with no configuration

Use the following run command to launch the CSV importer.

docker run \
--rm \
-p 8081:8080 \
fireflyiii/csv-importer:latest

By running this script, you will start a web server on port 8081 that will allow you to import data.

Useful scripts

The Docker GitHub repository has some useful scripts to get you started. They're ready-made and all you need to do it add configuration values.

Here are some tricks to make it easier for yourself:

Append "-d"

Change docker run to docker run -d to make sure the image runs in the background.

Run inline

This command will launch the CSV importer which will then try to import whatever it finds in the current directory. This is fully automated. It works by mounting the current directory to /import and importing all CSV files found inside of it.

As you can tell from the parameters, this little trick only works when you use a personal access token.

docker run \
--rm \
-v $PWD:/import \
-e FIREFLY_III_ACCESS_TOKEN= \
-e FIREFLY_III_URL= \
-e WEB_SERVER=false \
fireflyiii/csv-importer:latest

In order for this to work, each CSV file must be accompanied by a JSON configuration file. So import-file.csv must be accompanied by import-file.json.

This can also be made easier for yourself:

Use pre-defined script

Use run-inline.sh to make it easier to manage your Personal Access Token. You can also customize the directory that the script will use as well.

Docker container communication

When following the instructions above, the CSV importer will in a container separate from Firefly III itself. The communication between those containers can be done either by Docker internal IPs or internal URL's.

The IP address you need to contact Firefly III isn't 127.0.0.1, not even when you run Firefly III on the same machine. Docker uses an internal network.

URL in Docker

Docker comes with it's own DNS. Docker containers can communicate with each other via internal hostnames. The hostname of a Docker container is equal to the service name (e.g. as defined in your docker-compose.yml). This means you can set the URL parameter as follows:

FIREFLY_III_URL=http://fireflyiii:8080

-e FIREFLY_III_URL=http://fireflyiii:8080

Note that you do not need to add /callback here.

IP address in Docker

Should you wish to use internal Docker IP addresses instead, you need to find out your container's IP first. There's a good chance your Firefly III installation has an IP address that starts with 172.17. You can find out the internal IP address of Firefly III using this command:

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' CONTAINER

Instead of CONTAINER, use the container ID of your Firefly III installation.

If your Firefly III installation is online, you can also use the web address. If you want to, you can generate a Personal Access Token on the demo site and use the demo site as a test. Keep in mind that the demo site is public to everybody so everyone will see what you import.

Example scripts for a full setup

The commands below set up a basic MariaDB instance and an installation of Firefly III. It will then start the importer. This is just to show you what the relationship is between these different Docker images.

# run a basic MariaDB instance.
docker run --name mariadb -e MYSQL_ROOT_PASSWORD=super_secret -e MYSQL_DATABASE=fireflyiii -d mariadb:latest

# get the IP of the MariaDB instance:
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb

# run a basic Firefly III instance (update the IP of the database if necessary)
docker run -d \
--name fireflyiii \
-v firefly_iii_export:/var/www/firefly-iii/storage/export \
-v firefly_iii_upload:/var/www/firefly-iii/storage/upload \
-p 8081:8080 \
-e APP_KEY=123456789012345678901234567890aa \
-e DB_HOST=172.17.0.2 \
-e DB_CONNECTION=mysql \
-e DB_PORT=3306 \
-e DB_DATABASE=fireflyiii \
-e DB_USERNAME=root \
-e DB_PASSWORD=super_secret \
jc5x/firefly-iii:latest

# Chase the log files to see when Firefly III is ready to go:
docker logs -f $(docker container ls -a -f name=fireflyiii --format="{{.ID}}")

# get Firefly III IP address:
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker container ls -a -f name=fireflyiii --format="{{.ID}}")

# Adapt run-inline.sh and run it using your personal access token
# You can find it here: https://github.com/firefly-iii/csv-importer-docker/blob/master/run-inline.sh

./run-inline.sh

Docker and reverse proxies

Set the TRUSTED_PROXIES environment variable to the IP of your reverse proxy or **.

Make sure you properly configure your reverse proxy to forward the right info, like so for nginx.

proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;

Last update: 2021-01-25