To set up a production-ready Keycloak instance with MySQL using Docker Compose, you can follow these steps:
- Create a Docker Compose file named
docker-compose.ymlwith the following contents:
version: '3.7'
services:
keycloak:
image: jboss/keycloak:15.0.2
container_name: keycloak
environment:
- KEYCLOAK_USER=admin
- KEYCLOAK_PASSWORD=admin
- DB_VENDOR=mysql
- DB_ADDR=mysql
- DB_PORT=3306
- DB_DATABASE=keycloak
- DB_USER=keycloak
- DB_PASSWORD=password
ports:
- "8080:8080"
depends_on:
- mysql
mysql:
image: mysql:8.0.27
container_name: mysql
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=keycloak
- MYSQL_USER=keycloak
- MYSQL_PASSWORD=password
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
volumes:
mysql_data:
This file will create two services, one for Keycloak and one for MySQL, and link them together using the depends_on directive.
- Start the containers by running the following command in the same directory as your
docker-compose.ymlfile:
docker-compose up -d
This will start the Keycloak and MySQL containers in detached mode.
- Wait for a few moments for the containers to start up and then access the Keycloak Admin Console by visiting
http://localhost:8080/auth/admin/in your web browser. You can log in using the credentialsadmin/admin.
That's it! You now have a production-ready Keycloak instance with MySQL running in Docker. Note that this is just a basic configuration, and you may need to adjust it to suit your specific needs.
No comments:
Post a Comment