microsoft / mssql-docker

Official Microsoft repository for SQL Server in Docker resources
MIT License
1.74k stars 760 forks source link

chmod +x entrypoint.sh "operation not permitted" in derived images #541

Open chadgrant opened 4 years ago

chadgrant commented 4 years ago

The mssql user does not have permissions to make files executable, making it difficult to add startup/configure scripts.

the mssql-customize sample included in this repository does not work

vin-yu commented 4 years ago

One way to go around this is to perform these tasks outside before build and remove from the dockerfile as mssql in the container does not have access to making these executable depending on how they were copied into the container.

chmod +x configure-db.sh chmod +x entrypoint.sh

ikemtz commented 4 years ago

I ran into this issue, on my ikemtz/sql_dacpac image. My workaround was to switch to root, make the permission changes, then switch back to mssql user.

Here's a docker file for my image to use as an example: https://github.com/ikemtz/SQL_Dacpac

matthewturner commented 3 years ago

Thanks @ikemtz - this worked perfectly for me and seems an intuitive solution

m4cm3nz commented 2 years ago

A change in the mssql-customize sample and some kind of warning about the issue in te readme file, would be nice.

This work for me:

COPY --chown=root . /usr/config

# Grant permissions for to our scripts to be executable (YAGNI)
# RUN chmod +x /usr/config/entrypoint.sh
# RUN chmod +x /usr/config/configure-db.sh
mahahmadi360 commented 1 year ago

I had solved my problem with which m4cm3nz explained But now it says: exec ./entrypoint.sh: no such file or directory Any idea?

bgilbert6 commented 1 year ago

This worked for me


USER root

# Create a config directory
RUN mkdir -p /usr/config
WORKDIR /usr/config

# Bundle config source
COPY --chown=root . /usr/config

# Grant permissions for to our scripts to be executable
RUN chmod +x /usr/config/entrypoint.sh
RUN chmod +x /usr/config/configure-db.sh

ENTRYPOINT ["bash", "/usr/config/entrypoint.sh"]

Then in notepad++ I had to make sure the line endings were unix: https://stackoverflow.com/a/71324093/19535160

TeaDrinkingProgrammer commented 8 months ago

You can also use dos2unix to automatically change the line-endings. This way, you know for certain that can't go wrong again.

# Install dos2unix
RUN apt update && apt install dos2unix

# Change DOS line-endings to Unix line-endings
RUN dos2unix /usr/config/entrypoint.sh