I have been trying to dockerize both a MySQL database and a Go REST server together. This exact configuration has worked for me in the past, and is no longer working. Cannot find a solution anywhere.
version: '3'
services:
db:
image: mysql
restart: always
expose:
- 3306
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=puapp
volumes:
- db_volume:/var/lib/mysql
- ./mysql:/docker-entrypoint-initdb.d/:ro
api-service:
build: ../..
restart: always
ports:
- "80:8080"
expose:
- 8080
environment:
- DB_USER=root
- DB_PASS=root
- DB_ADDRESS=db:3306
- DB_PROTOCOL=tcp
- DB_NAME=puapp
depends_on:
- db
links:
- db
volumes:
db_volume:
Error:
feature-db-1 | 2021-11-22 22:39:27 00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/dump.sql
feature-db-1 | /usr/local/bin/docker-entrypoint.sh: line 75: /docker-entrypoint-initdb.d/dump.sql: Permission denied
CodePudding user response:
Your container cannot read the file dump.sql in /docker-entrypoint-initdb.d/ which mount to the directory on your host ./mysql. chmod 777 ./mysql
to allow the read.