我有以下docker-compose.yml文件:
version: "3" services:\ local_db:
build:
context: mssql-data
dockerfile: Dockerfile
ports:
- "1433:1433"
volumes:
- ~/Documents/rfg/temp
environment:
SA_PASSWORD: "D0ckerDev"
ACCEPT_EULA: "Y"
当我运行docker-compose up时,出现以下错误:
local_db_1 | /scripts/entrypoint.sh: line 5: /scripts/seed-data.sh: Permission denied
docker_local_db_1 exited with code 126
入口点是:
#start SQL Server in the background
/opt/mssql/bin/sqlservr &
# start the seed data script
/scripts/seed-data.sh
seed-data.sh在哪里:
sleep 15s cd /scripts
if [ -f /var/opt/mssql/data/initialized ]; then
sleep infinity
fi sleep 15s /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SA_PASSWORD -d master -i setup.sql
touch /var/opt/mssql/data/initialized sleep infinity
和entrypoint.sh:
#start SQL Server in the background
/opt/mssql/bin/sqlservr &
# start the seed data script
/scripts/seed-data.sh
和Dockerfile:
FROM microsoft/mssql-server-linux:2017-latest
COPY . /scripts
CMD chmod 755 /scripts/*
CMD chmod 755 /scripts/seed-data.sh
CMD /bin/bash /scripts/entrypoint.sh
上面的方法在Windows中工作正常,但是在MacOS上,我遇到了上面的“拒绝权限”错误。
答案 0 :(得分:2)
您似乎没有对seed-data.sh
脚本设置正确的权限。您可以这样称呼它:
sh /scripts/seed-data.sh
或者您可以确保所有脚本都首先可执行:
chmod 755 /scripts/*
/scripts/seed-data.sh