Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing permissions to create a directory in the database container #2

Open
pauldj54 opened this issue Jan 17, 2023 · 1 comment
Open

Comments

@pauldj54
Copy link

Hi @tometchy ,
Great stuff, it helped me a lot, but I had to modify the Docker file for the mssql to execute the mkdir and chmod commands as root user and then back to the mssql user for the scripts part as follows:

# We choose exact tag (not 'latest'), to be sure that new version won't break creating image
FROM mcr.microsoft.com/mssql/server:2019-latest

# change active user to root
USER root

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Copy initialization scripts
COPY . /usr/src/app

# Grant permissions for the run-initialization script to be executable
RUN chmod +x /usr/src/app/run-initialization.sh

# change back to user mssql
USER mssql

# Set environment variables, not to have to write them with docker run command
# Note: make sure that your password matches what is in the run-initialization script 
ENV SA_PASSWORD CorrectHorseBatteryStapleFor$
ENV ACCEPT_EULA Y
ENV MSSQL_PID Express

# Expose port 1433 in case accesing from other container
EXPOSE 1433

# Run Microsoft SQl Server and initialization script (at the same time)
# Note: If you want to start MsSQL only (without initialization script) you can comment bellow line out, CMD entry from base image will be taken
CMD /bin/bash ./entrypoint.sh

Could you please have a look and update the file if this is correct?

@tometchy
Copy link
Owner

You're right, the policy has changed, thanks for the comment. I will look at it more carefully (at the evening probably) and then change the file. In case you or some other reader doesn't know - this can be changed at the docker-compose file level as well, but your approach with adding it to Dockerfile looks simpler. Thanks again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants