sql-serverdocker-composedockerfile

When creating a SQL Server Instance from a Dockerfile, It does not seem to pick up the SA password


I had created a SQL Server docker container instance previously and was able to successfully log in. I removed that image and was migrating the code from a docker run command into a docker-compose with a backed Dockerfile.

I have the ENV MSSQL_SA_PASSWORD set in the dockerfile but, now, when I try and log in, it gives me an error: Login failed for user 'sa'". It seems like it is caching it somewhere and I no longer remember what that password was.

How do I remedy this and have the container only use the password set in the Dockerfile?

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

COPY source/database/scripts /usr/src/app

ENV MSSQL_SA_PASSWORD "MyPassword1"
ENV ACCEPT_EULA Y

# Run SQL Server process
ENTRYPOINT [ "/opt/mssql/bin/sqlservr" ]

Thanks


Solution

  • The three most common issues with the sa password in Docker: