I'm working with Windows 10 system. I run docker-compose up -d to start postgresql and keycloak images. I use docker volume to save database data. My docker-compose file content:
version: '2.2'
volumes:
files_volume:
driver: local
services:
postgres:
image: postgres:12
container_name: test_postgres
volumes:
- files_volume:/var/lib/postgresql/data
expose:
- 5432
ports:
- "15432:5432"
environment:
- "POSTGRES_DB=test"
- "POSTGRES_USER=super-admin"
- "POSTGRES_PASSWORD=super-password"
mem_limit: 256m
restart: unless-stopped
keycloak:
image: jboss/keycloak:10.0.2
hostname: keycloak
container_name: keycloak
volumes:
- files_volume:/opt/jboss/keycloak/standalone/log
environment:
DB_VENDOR: POSTGRES
DB_ADDR: 'postgres'
DB_DATABASE: 'test'
DB_USER: 'super-admin'
DB_SCHEMA: 'keycloak'
DB_PASSWORD: 'super-password'
KEYCLOAK_USER: 'admin'
KEYCLOAK_PASSWORD: 'admin'
PROXY_ADDRESS_FORWARDING: 'true'
JDBC_PARAMS: 'useSSL=false'
expose:
- 8080
ports:
- "18080:8080"
mem_limit: 1024m
restart: unless-stopped
depends_on:
postgres:
condition: service_started
Docker starts normally, but I can't see keycloak schema on this postgres database. When I connect to keycloak and create realm, clients and so on and docker-compose down after restarting I see that there is no data left for keycloak. No realm, no clients, nothing. I believe that keycloak doesn't see postgres and use H2 database.
I use volume because I can't use direct folder. Maybe I'm doing something wrong with volumes? I am quite new to docker.
I solved problem by stopping docker compose and removing keycloak and postgres containers. Then removed volume. Then started docker-compose and everything worked just fine. I believe, that I was starting docker old containers with docker compose, they were cached. So, every time when changing docker compose file, the container, which properties were changed, must be removed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.