I have this Dockerfile to customize a SQL Server image for our developers:

FROM mcr.microsoft.com/mssql/server:latest
ENV PATH="${PATH}:/Company/Commands/DatabaseContainer"
USER root

And it works well. However, we have some functions and procedures that we add to master and model databases and right now our developers need to run them manually.

I wonder, if it's possible for me to add them during the creation of this docker image?

Is that possible and if so, how?

P.S. I already know about entrypoint, but it is not embedded into the image.

  • Can't you install sqlcmd temporarily, COPY the SQL files with the definitions, and RUN sqlcmd -i file1.sql,file2.sql?
    – dezso
    Sep 23 at 12:30
  • @dezso, the point is, sqlserver process is not started yet. That can not be done I guess. Maybe I can start the process, and wait for it to load, and run scripts. I have to test it.
    – Ali EXE
    Sep 23 at 12:53
  • 1
    You mentioned main and model databases. Do you mean master and model?
    – Dan Guzman
    Sep 23 at 18:00
  • @DanGuzman, yes, my bad. I meant master.
    – Ali EXE
    Sep 27 at 6:00


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.