Docker Community Forums

Share and learn in the Docker community.

Volumen shared with host and container

What is the best option in docker compose to create a persistent volume of host inside of container, for example for jboss eap container,

You can’t create a persistent volume inside of the container, as that’s destroyed when you stop the container running. You create a persistent volume on the server you’re running docker on instead. At least, this is what I think you mean.

To boot in standalone mode

docker run jboss/keycloak
Expose on localhost
To be able to open Keycloak on localhost map port 8080 locally

docker run -p 8080:8080 jboss/keycloak
Creating admin account
By default there is no admin user created so you won’t be able to login to the admin console. To create an admin account you need to use environment variables to pass in an initial username and password. This is done by running:

docker run -e KEYCLOAK_USER= -e KEYCLOAK_PASSWORD= jboss/keycloak
You can also create an account on an already running container by running:

docker exec /opt/jboss/keycloak/bin/add-user-keycloak.sh -u -p
Then restarting the container:

docker restart
Providing the username and password via files
By appending _FILE to the two environment variables used above (KEYCLOAK_USER_FILE and KEYCLOAK_PASSWORD_FILE), the information can be provided via files instead of plain environment variable values. The configuration and secret support in Docker Swarm is a perfect match for this use case.