Balwan singh
08/22/2023, 7:12 AMoguzhan
localhost:3306
?Balwan singh
08/22/2023, 8:50 AMoguzhan
cerbos
and mysql
?Balwan singh
08/22/2023, 9:36 AMoguzhan
cerbos
in a container but mysql
in the host machine.Balwan singh
08/22/2023, 9:58 AMBalwan singh
08/22/2023, 9:58 AMoguzhan
mysql
service into the docker-compose.yaml
, and changing cerbos configuration to connect to it.
docker-compose.yaml
should look something like this;
version: "3.9"
services:
cerbos:
container_name: cerbos
image: <http://ghcr.io/cerbos/cerbos:latest|ghcr.io/cerbos/cerbos:latest>
restart: always
command: ["server", "--config=/config/conf.yaml", "--log-level=warn"]
volumes:
- ./cerbos/config:/config
- ./cerbos/policies:/policies
ports:
- 3592:3592
- 3593:3593
admin-api:
container_name: admin-api
build: .
environment:
- CERBOS_HOST=cerbos
ports:
- 8090:8090
depends_on:
- cerbos
mysql:
container_name: mysqlstore
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
- MYSQL_DATABASE=cerbos
- MYSQL_ROOT_PASSWORD=cerbos
- MYSQL_USER=cerbos
- MYSQL_PASSWORD=cerbos
volumes:
- ./data:/var/lib/mysql
ports:
- 127.0.0.1:3306:3306
and the dsn in the cerbos configuration should be like this: cerbos:cerbos123@tcp(mysqlstore:3306)/cerbos
Balwan singh
08/22/2023, 11:21 AMoguzhan
3306
port is not available. That’s probably because you have a mysql instance running on your host machine occupying the port 3306
.Balwan singh
08/22/2023, 11:46 AMoguzhan
host.docker.internal
could work. (Ex: cerbos:cerbos123@tcp(host.docker.internal:3306)/cerbos
)Balwan singh
08/22/2023, 12:13 PM