Skip to content

Instantly share code, notes, and snippets.

@abdullah-shiwani
Last active August 13, 2018 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdullah-shiwani/b02d238bb1279deb73376ddf3e4b11ee to your computer and use it in GitHub Desktop.
Save abdullah-shiwani/b02d238bb1279deb73376ddf3e4b11ee to your computer and use it in GitHub Desktop.
Keycloak with postgres docker-compose
version: '3'
services:
postgres:
image: postgres:latest
restart: always
volumes:
- ./pgdata:/var/lib/postgresql/data
environment:
POSTGRES_DB: keycloak
POSTGRES_USER: keycloak
POSTGRES_PASSWORD: password
keycloak:
image: jboss/keycloak
restart: always
links:
- postgres
ports:
- "8080:8080"
environment:
KEYCLOAK_USER : admin
KEYCLOAK_PASSWORD: admin1234
DB_VENDOR: postgres
DB_ADDR: postgres
DB_DATABASE: keycloak
DB_USER: keycloak
DB_PASSWORD: password

Docker will create a directory called 'pgdata' to store Postgres data. This is how data will not be wiped out every time the container restarts.

Docker Compose

### cwd to directory of docker-compose.yml

# Run all containers in a compose file
docker-compose up -d
## -d means detach, it will run containers and detach from stdout

# Run a container
docker-compose up <name>

# Stop a container
docker-compose stop <name>

# Stop and remove a container
docker-compose down <name>

# Stop and remove all container
docker-compose down

Can be accessable at http://localhost:8080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment