Skip to content

About

Docker images for Firebird Database

Topics

Resources

Contributing

Stars

54 stars

Watchers

10 watching

Forks

Repository files navigation

firebird-docker

Docker images for Firebird Database.

Quick reference

Supported tags

firebirdsql/firebird Dockerfile
5.0.4-bookworm, 5-bookworm, bookworm Dockerfile
5.0.4-jammy, 5-jammy, jammy Dockerfile
5.0.4-noble, 5-noble, noble Dockerfile
5.0.4-trixie, 5-trixie, trixie, 5.0.4, 5, latest Dockerfile
5.0.3-bookworm Dockerfile
5.0.3-jammy Dockerfile
5.0.3-noble Dockerfile
5.0.3-trixie, 5.0.3 Dockerfile
5.0.2-bookworm Dockerfile
5.0.2-jammy Dockerfile
5.0.2-noble Dockerfile
5.0.2-trixie, 5.0.2 Dockerfile
5.0.1-bookworm Dockerfile
5.0.1-jammy Dockerfile
5.0.1-noble Dockerfile
5.0.1-trixie, 5.0.1 Dockerfile
5.0.0-bookworm Dockerfile
5.0.0-jammy Dockerfile
5.0.0-noble Dockerfile
5.0.0-trixie, 5.0.0 Dockerfile
4.0.7-bookworm, 4-bookworm Dockerfile
4.0.7-jammy, 4-jammy Dockerfile
4.0.7-noble, 4-noble Dockerfile
4.0.7-trixie, 4-trixie, 4.0.7, 4 Dockerfile
4.0.6-bookworm Dockerfile
4.0.6-jammy Dockerfile
4.0.6-noble Dockerfile
4.0.6-trixie, 4.0.6 Dockerfile
4.0.5-bookworm Dockerfile
4.0.5-jammy Dockerfile
4.0.5-noble Dockerfile
4.0.5-trixie, 4.0.5 Dockerfile
4.0.4-bookworm Dockerfile
4.0.4-jammy Dockerfile
4.0.4-noble Dockerfile
4.0.4-trixie, 4.0.4 Dockerfile
4.0.3-bookworm Dockerfile
4.0.3-jammy Dockerfile
4.0.3-noble Dockerfile
4.0.3-trixie, 4.0.3 Dockerfile
4.0.2-bookworm Dockerfile
4.0.2-jammy Dockerfile
4.0.2-noble Dockerfile
4.0.2-trixie, 4.0.2 Dockerfile
4.0.1-bookworm Dockerfile
4.0.1-jammy Dockerfile
4.0.1-noble Dockerfile
4.0.1-trixie, 4.0.1 Dockerfile
4.0.0-bookworm Dockerfile
4.0.0-jammy Dockerfile
4.0.0-noble Dockerfile
4.0.0-trixie, 4.0.0 Dockerfile
3.0.14-bookworm, 3-bookworm Dockerfile
3.0.14-jammy, 3-jammy Dockerfile
3.0.14-noble, 3-noble Dockerfile
3.0.14-trixie, 3-trixie, 3.0.14, 3 Dockerfile
3.0.13-bookworm Dockerfile
3.0.13-jammy Dockerfile
3.0.13-noble Dockerfile
3.0.13-trixie, 3.0.13 Dockerfile
3.0.12-bookworm Dockerfile
3.0.12-jammy Dockerfile
3.0.12-noble Dockerfile
3.0.12-trixie, 3.0.12 Dockerfile
3.0.11-bookworm Dockerfile
3.0.11-jammy Dockerfile
3.0.11-noble Dockerfile
3.0.11-trixie, 3.0.11 Dockerfile
3.0.10-bookworm Dockerfile
3.0.10-jammy Dockerfile
3.0.10-noble Dockerfile
3.0.10-trixie, 3.0.10 Dockerfile
3.0.9-bookworm Dockerfile
3.0.9-jammy Dockerfile
3.0.9-noble Dockerfile
3.0.9-trixie, 3.0.9 Dockerfile

Snapshot (pre-release) images

Pre-release builds from the Firebird development branches are available as snapshot images:

Tag Source Branch Description
6-snapshot master Firebird 6.x development builds
5-snapshot v5.0-release Firebird 5.x next-patch builds

Warning: Snapshot images are built from unreleased code and may be unstable. They are rebuilt daily and replaced on each build. Do not use in production.

# Pull latest Firebird 6.x development snapshot
docker pull firebirdsql/firebird:6-snapshot

# Pull latest Firebird 5.x patch snapshot
docker pull firebirdsql/firebird:5-snapshot

Architectures

Images for Firebird 5.x and later are available for both linux/amd64 and linux/arm64. Firebird 3.x and 4.x images are linux/amd64 only.

Discontinued distributions

Debian 11 bullseye images (*-bullseye tags) are no longer built, because Debian 11 reached its end of life. The tags already published remain available, but they will not receive any updates, including security fixes. Please move to trixie (the default) or bookworm.

How to use this image

Image defaults:

  • EXPOSE 3050/tcp
  • VOLUME /var/lib/firebird/data

Start a Firebird server instance

docker run \
    -e FIREBIRD_ROOT_PASSWORD=************ \
    -e FIREBIRD_USER=alice \
    -e FIREBIRD_PASSWORD=************ \
    -e FIREBIRD_DATABASE=mirror.fdb \
    -e FIREBIRD_DATABASE_DEFAULT_CHARSET=UTF8 \
    -v ./data:/var/lib/firebird/data \
    --detach firebirdsql/firebird
services:
  firebird:
    image: firebirdsql/firebird
    restart: always
    environment:
      - FIREBIRD_ROOT_PASSWORD=************
      - FIREBIRD_USER=alice
      - FIREBIRD_PASSWORD=************
      - FIREBIRD_DATABASE=mirror.fdb
      - FIREBIRD_DATABASE_DEFAULT_CHARSET=UTF8
    volumes:
      - ./data:/var/lib/firebird/data

Connect to an existing instance using isql

docker run -it --rm firebirdsql/firebird isql -u SYSDBA -p ************ SERVER:/path/to/file.fdb

Environment variables

The following environment variables can be used to customize the container.

FIREBIRD_ROOT_PASSWORD

Firebird installer generates a one-off password for SYSDBA and stores it in /opt/firebird/SYSDBA.password.

If FIREBIRD_ROOT_PASSWORD is set, SYSDBA password will be changed. And the file /opt/firebird/SYSDBA.password will be removed.

FIREBIRD_USER

Creates an user in Firebird security database.

You must inform a password in FIREBIRD_PASSWORD variable. Otherwise the container initialization will fail.

If the username is not a regular SQL identifier (e.g. it contains dots or dashes, like dba.backend) it will be created as a delimited identifier, which is case-sensitive in Firebird. Clients must then connect quoting the username in double quotes, e.g. isql -u '"dba.backend"'.

FIREBIRD_DATABASE

Creates a new database. Ignored if the database already exists.

Database location is /var/lib/firebird/data. Absolute paths (outside this folder) are allowed.

You may use FIREBIRD_DATABASE_PAGE_SIZE to set the database page size. And FIREBIRD_DATABASE_DEFAULT_CHARSET to set the default character set.

FIREBIRD_USE_LEGACY_AUTH

Enables legacy authentication (not recommended).

FIREBIRD_CONF_*

Any variable starting with FIREBIRD_CONF_ can be used to set values in Firebird configuration file (firebird.conf).

E.g. You can use FIREBIRD_CONF_DataTypeCompatibility=3.0 to set the value of key DataTypeCompatibility to 3.0 in firebird.conf.

Please note that keys are case sensitive. And any key not present in firebird.conf will be ignored.

*_FILE

Any of the previously listed environment variables may be loaded from file by appending the _FILE suffix to the variable name.

E.g. FIREBIRD_PASSWORD_FILE=/run/secrets/firebird-passwd will load FIREBIRD_PASSWORD with the content from /run/secrets/firebird-passwd file.

Note that both the original variable and its _FILE variant are mutually exclusive. Trying to use both will cause the container initialization to fail.

Using database aliases

To use database aliases, create your own databases.conf file and configure a Docker bind mount for it at /opt/firebird/databases.conf.

IMPORTANT: A bind mount replaces the entire file inside the container. The default databases.conf shipped with the image contains a required entry for the security database (security.db). If your file does not include this entry, Firebird cannot open the security database and the container will fail to start with an error like:

I/O error during "open" operation for file "security.db"

To keep the required entries, start from the default file of the image and append your aliases to it:

# Extract the default databases.conf from the image
docker run --rm firebirdsql/firebird cat /opt/firebird/databases.conf > databases.conf

# Append your aliases
echo "mydb = /var/lib/firebird/data/mydb.fdb" >> databases.conf

# Use it with a bind mount
docker run -d --mount type=bind,src=$(pwd)/databases.conf,dst=/opt/firebird/databases.conf \
    -e FIREBIRD_ROOT_PASSWORD=my_secret_password firebirdsql/firebird

Extracting the file from the same image (and tag) you run also ensures you get the correct security database entry, which is different for each Firebird version.

More information:

Persisting the security database

Firebird users are stored in the security database: /opt/firebird/security5.fdb (security4.fdb for Firebird 4, security3.fdb for Firebird 3). This includes users created with FIREBIRD_USER, with CREATE USER, or by your application.

This file is part of the container, not of the /var/lib/firebird/data volume. It is kept when the container restarts, but a new container (e.g. after docker compose down and up, or when upgrading the image) starts with the default security database of the image. Only SYSDBA and FIREBIRD_USER are then set up again.

To keep your users, store the security database outside the container with a Docker bind mount. Start from the default file of the image:

# Extract the default security database from the image
docker create --name fb-tmp firebirdsql/firebird
docker cp fb-tmp:/opt/firebird/security5.fdb ./security5.fdb
docker rm fb-tmp

# Use it with a bind mount
docker run -d --mount type=bind,src=$(pwd)/security5.fdb,dst=/opt/firebird/security5.fdb \
    -v ./data:/var/lib/firebird/data \
    -e FIREBIRD_ROOT_PASSWORD=my_secret_password firebirdsql/firebird

Or, with Docker Compose:

    volumes:
      - ./data:/var/lib/firebird/data
      - ./security5.fdb:/opt/firebird/security5.fdb

IMPORTANT:

  • The file must exist on the host before the container starts. With -v (or a Compose short syntax volume), a missing file is silently created as an empty directory, and Firebird cannot open the security database. --mount fails with an error instead.
  • Use the file name of the Firebird version you run, and extract it from an image of that same major version.
  • Do not rely on /opt/firebird/SYSDBA.password: it belongs to the container, not to your security database, and is not kept with it. Set FIREBIRD_ROOT_PASSWORD on every start, or keep track of the SYSDBA password yourself.
  • When running as a non-root user, the file must be writable by that user (e.g. chown 84:0 security5.fdb).
  • Never use the same file in two containers running at the same time.

Using Firebird Events

To use this image with Firebird Events you need to:

  • use FIREBIRD_CONF_RemoteAuxPort environment variable to set the value of RemoteAuxPort configuration to a specific port (e.g. 3051); and
  • Publish this port to the host.

More information:

Initializing the database contents

When creating a new database with FIREBIRD_DATABASE environment variable you can initialize it running one or more shell or SQL scripts.

Any file with extensions .sh, .sql, .sql.gz, .sql.xz and .sql.zst found in /docker-entrypoint-initdb.d/ will be executed in alphabetical order. .sh files without file execute permission (+x) will be sourced rather than executed.

IMPORTANT: Scripts will only run if you start the container with a data directory that is empty. Any pre-existing database will be left untouched on container startup.

Setting container time zone

The container runs in the UTC time zone by default. To change this, you can set the TZ environment variable:

    environment:
      - TZ=America/New_York

Alternatively, you can use the same time zone as your host system by mapping the /etc/localtime and /etc/timezone system files:

    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro

Backup and Restore

For online databases

If the database is in use, call gbak inside the running container using Firebird Service Manager (-se switch) for best performance.

The following commands will backup and restore a database in the data directory (/var/lib/firebird/data) of the running container.

# Online backup
FIREBIRD_CONTAINER=MY_CONTAINER_NAME_OR_ID
DATABASE_FILE=MY_DATABASE.fdb
BACKUP_FILE=MY_DATABASE.fbk

docker exec $FIREBIRD_CONTAINER bash -c "gbak -b -user SYSDBA -pas \$FIREBIRD_ROOT_PASSWORD -se localhost:service_mgr \$FIREBIRD_DATA/$DATABASE_FILE \$FIREBIRD_DATA/$BACKUP_FILE"
# Online restore
FIREBIRD_CONTAINER=MY_CONTAINER_NAME_OR_ID
BACKUP_FILE=MY_DATABASE.fbk
DATABASE_FILE=MY_DATABASE.fdb

docker exec $FIREBIRD_CONTAINER bash -c "gbak -c -user SYSDBA -pas \$FIREBIRD_ROOT_PASSWORD -se localhost:service_mgr \$FIREBIRD_DATA/$BACKUP_FILE \$FIREBIRD_DATA/$DATABASE_FILE"

For offline databases

IMPORTANT: Never use this with online (running) database files.

If you don't have a running server, create an ephemeral container to run gbak directly over the database files.

The following commands will backup and restore a database in the current directory ($PWD).

# Offline backup
FIREBIRD_IMAGE=firebirdsql/firebird
DATABASE_FILE=MY_DATABASE.fdb
BACKUP_FILE=MY_DATABASE.fbk

docker run --rm -v .:/pwd $FIREBIRD_IMAGE gbak -b /pwd/$DATABASE_FILE /pwd/$BACKUP_FILE 
# Offline restore
FIREBIRD_IMAGE=firebirdsql/firebird
BACKUP_FILE=MY_DATABASE.fbk
DATABASE_FILE=MY_DATABASE.fdb

docker run --rm -v .:/pwd $FIREBIRD_IMAGE gbak -c /pwd/$BACKUP_FILE /pwd/$DATABASE_FILE

More information:

About

Docker images for Firebird Database

Topics

Resources

Contributing

Stars

54 stars

Watchers

10 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages