Adding a Database for Dockerfiles
Learn how to add a database to your Dockerfile (non-Compose) based environment.
If you’re using Compose, follow the databases for Compose guide.
Adding Your Database Service
From the Containers page, click the Add Services button and select the Non-Repository tab.
Choose your database, give your service a name, and create it.
Note: You can set environment variables by clicking the gear icon next to its name. Environment variables can be used to define credentials, or form container connections.
Seeding Your Database
Creating a Seed File
You can clone an existing database to create a seed file. Here’s how to create one:
$ mysqldump --all-databases -u mysql -p > seed.sql
$ pg_dump -U postgres -Fc postgres -f seed.dump
Note: The default password is
You are now the proud owner of a
Using the Seed File
Open the configuration for your database by clicking the gear icon next to its name, and select the Dockerfile tab.
Open the file menu by clicking the + icon in the file browser and select Upload File.
Select and upload your
seed.dumpfile to your container.
In the file editor, uncomment the
ADDcommand and replace
[src]with the path to your dump file, relative to your Dockerfile:
ADD [src] /seed.sql
ADD [src] /seed.dump
Note: Do not modify the destination
/seed.dump; it’s required to for the initialization script.
Your seeded database will now be created for all new builds.