You don't. All you have to do is pass the
url, user, password information as environment variables to your docker image.But before being able to do that, you will need to have the db driver auto-configured. Because it's a runtime property and default to H2 database.
1) Extends the docker image by specifying the database driver (something like the following):
2) And I can create the container with the following arguments assuming that you've built the container with the tag keycloak-x:1.1:
docker run -d --name keycloak -p 8080:8080 -p 8443:8443 \
-e KEYCLOAK_ADMIN=xxxx \ -e KEYCLOAK_ADMIN_PASSWORD=xxxx \ -e KC_DB_URL=jdbc:postgresql://172.17.0.2:5432/keycloak \ -e KC_DB_USERNAME=keycloak \ -e KC_DB_PASSWORD=keycloak \ keycloak-x:1.1