Skip to content

Conversation

@shanegenschaw
Copy link

Applies to mssql-server-linux, issue #11, adding functionality to mount initialization scripts and execute them when the container is started.

When a container is started for the first time, it will execute any files with extensions .sh or .sql that are found in /docker-entrypoint-initdb.d. Files will be executed in alphabetical order. You can easily populate your SQL Server services by mounting scripts into that directory and provide custom images with contributed data.

@shanegenschaw
Copy link
Author

Looks like this may also help resolve issue #2 and #49

@twright-msft
Copy link
Collaborator

@shanegenschaw - Thanks for submitting this PR. Our plan is to add this functionality to a hopefully near future release of SQL Server. The current thinking is that we would have the sqlservr process execute these SQL scripts on startup as opposed to a .sh with sqlcmd. That way we can have a universal solution for SQL on Linux and on Windows. The sqlservr process could look for an env variable which contained either a directory path to a set of files or a json formatted list of full paths to files. What do you think about that approach?

@shanegenschaw
Copy link
Author

@twright-msft - your approach sounds fantastic. Good idea to have a universal & consistent solution across platforms. Thanks for your consideration!

@twright-msft
Copy link
Collaborator

OK cool. We'll get 'er done then. We'll close out this PR since it will be implemented in a different but conceptually similar way. Thanks for contributing and keep the suggestions/PRs coming!

@kspearrin
Copy link

kspearrin commented Aug 18, 2017

@twright-msft Was this ever done? Not able to find any docs about it. For now I'm trying to run an entrypoint.sh but that doesn't work since you have to call /opt/mssql/bin/sqlservr first to start up sql server and that never returns. ex:

Dockerfile

FROM microsoft/mssql-server-linux

COPY setup.sql /

COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

entrypoint.sh

#!/bin/sh

/opt/mssql/bin/sqlservr
# the above never returns so the script below doesn't get run... :(
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -i /setup.sql

@twright-msft
Copy link
Collaborator

Take a look at this example:
https://github.com/twright-msft/mssql-node-docker-demo-app

@manish-panwar
Copy link

Any luck on having a better solution?

@potatoqualitee
Copy link

Our plan is to add this functionality to a hopefully near future release of SQL Server.

Any chance this can be in 2022? 😊

@tracker1
Copy link

Something to look at...

https://github.com/tracker1/mssql-docker-enhanced

@potatoqualitee
Copy link

Thank you but I am looking for official Microsoft support

@jrichardsz
Copy link

jrichardsz commented May 9, 2023

2023 and nothing.

The official demo https://github.com/mcmoe/mssqldocker is a fat container, which is not a good idea.

Mysql, MariaDb, Postgress, even Oracle has the classic

    volumes:
     - ./my/database:/docker-entrypoint-initdb.d 

@shanegenschaw your approach was good. No body uses windows for docker :(

@srstsavage
Copy link

srstsavage commented May 25, 2023

+1, it's been six years, let's be realistic and not let the perfect be the enemy of the good. Can this please get re-opened and merged?

@davidmpaz
Copy link

Hi @twright-msft,

regarding your statement:

OK cool. We'll get 'er done then. We'll close out this PR since it will be implemented in a different but conceptually similar way. Thanks for contributing and keep the suggestions/PRs coming!

Is this still the case? Can the community expect any outcome in this direction?

Thanks in advance,
David

@potatoqualitee
Copy link

Our plan is to add this functionality to a hopefully near future release of SQL Server.

Any chance this can be in 2022? 😊

Any chance this can be in 2025? 😊

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

Successfully merging this pull request may close these issues.

9 participants