meds
meds

Reputation: 22926

docker-compose up permission denied on sh file

I have the following docker-compose.yml file:

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"

When I run docker-compose up I get the following error:

local_db_1  | /scripts/entrypoint.sh: line 5: /scripts/seed-data.sh: Permission denied
docker_local_db_1 exited with code 126

Where entry point is:

#start SQL Server in the background
/opt/mssql/bin/sqlservr &

# start the seed data script 
/scripts/seed-data.sh

Where seed-data.sh was:

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

and entrypoint.sh:

#start SQL Server in the background
/opt/mssql/bin/sqlservr &

# start the seed data script 
/scripts/seed-data.sh

and the 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

The above works fine in Windows but on MacOS I get th epermission denied error above..

Upvotes: 3

Views: 10451

Answers (1)

larsks
larsks

Reputation: 311606

It looks like you haven't set the correct permissions on your seed-data.sh script. You could just call it like this:

sh /scripts/seed-data.sh

Or you can make sure all your scripts are executable first:

chmod 755 /scripts/*
/scripts/seed-data.sh

Upvotes: 12

Related Questions