mssql-docker icon indicating copy to clipboard operation
mssql-docker copied to clipboard

Unable to build an image which runs a setup script using the example

Open russellgeraghty-bjss opened this issue 2 years ago • 4 comments

Hi, In the linux/preview/examples/mssql-customize/Dockerfile the setup scripts create directories in /usr/config. With the latest tag at cc5e303024cf56953f3cebfcd291f2eaba1b899f0bca0f0a9a827bf450fee488, we get a permission denied error creating anything in /usr/.

Building 0.9s (6/10)
 => [internal] load build definition from Dockerfile                                                                                                                        
 => => transferring dockerfile: 32B                                                                                                                                        
 => [internal] load .dockerignore                                                                                                                                            
 => => transferring context: 2B                                                                                                                                            
 => [internal] load metadata for mcr.microsoft.com/mssql/server:2022-latest                                                                                                  
 => [1/6] FROM mcr.microsoft.com/mssql/server:2022-latest                                                                                                                    
 => [internal] load build context                                                                                                                                           
 => => transferring context: 599B                                                                                                                                            
 => ERROR [2/6] RUN mkdir -p /usr/config                                                                                                                                    
------
 > [2/6] RUN mkdir -p /usr/config:
#0 0.318 /usr/bin/mkdir: cannot create directory '/usr/config': Permission denied
------
failed to solve: executor failed running [/bin/sh -c mkdir -p /usr/config]: exit code: 1

We've switched to using /tmp and that seems to be working.

Cheers Russell.

russellgeraghty-bjss avatar Jul 14 '23 10:07 russellgeraghty-bjss

Hi @russellgeraghty-bjss, I was having the same problem but if I change the folder now I get an error about the complexity of the password:

Password validation failed. The password does not meet SQL Server password policy requirements because it is not complex enough. The password must be at least 8 characters long and contain characters from three of the following four sets: Uppercase letters, Lowercase letters, Base 10 digits, and Symbols. Msg 15007, Level 16, State 1, Server 6999b8cad24a, Line 1

I find this strange since the password I am using meets these conditions. Didn't you have a similar error?

FrancoLiberali avatar Aug 16 '23 13:08 FrancoLiberali

The following is required. Credit where credit is due: source.

FROM mcr.microsoft.com/mssql/server:2022-latest

#RUN whoami

# Change active user to root
USER root 

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

# Set mssql as owner of the app directory
RUN chown mssql /usr/config

WORKDIR /usr/config

# Bundle config source
COPY . /usr/config

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

# Change back to user mssql
USER mssql

ENTRYPOINT ["./entrypoint.sh"]

I'll submit a PR to this repo to update the example once I get everything working, as I'm currently getting exec ./entrypoint.sh: exec format error when I run the image :(

benmccallum avatar Sep 20 '23 06:09 benmccallum

Thx @benmccallum This works for me.

bassiounix avatar Nov 03 '23 20:11 bassiounix

Hi @russellgeraghty-bjss, I was having the same problem but if I change the folder now I get an error about the complexity of the password:

Password validation failed. The password does not meet SQL Server password policy requirements because it is not complex enough. The password must be at least 8 characters long and contain characters from three of the following four sets: Uppercase letters, Lowercase letters, Base 10 digits, and Symbols. Msg 15007, Level 16, State 1, Server 6999b8cad24a, Line 1

I find this strange since the password I am using meets these conditions. Didn't you have a similar error?

Maybe your password contains the username which is not allowed according to the password policy, though it's not mentioned in the error message. See #861.

8ware avatar Nov 13 '23 09:11 8ware