Microsoft SQL Server on Linux for Docker Engine. Learn more about the latest release of SQL Server on Linux here: SQL Server on Linux Documentation. For any questions or issues, please contact us through a GitHub issue.
- Dockerfile: mssql-server-linux:latest
Additional Microsoft SQL Server Docker Images
- SQL Server for Windows Containers: microsoft/mssql-server-windows
- SQL Server Express for Windows Containers: microsoft/mssql-server-windows-express
- This image requires Docker Engine 1.8+ in any of their supported platforms.
- At least 3.25 GB of RAM. Make sure to assign enough memory to the Docker VM if you're running on Docker for Mac or Windows.
- Requires the following environment flags
- A strong system administrator (SA) password: At least 8 characters including uppercase, lowercase letters, base-10 digits and/or non-alphanumeric symbols.
How to use this image
Start a mssql-server instance
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d microsoft/mssql-server-linux
Connect to Microsoft SQL Server
Starting with the CTP 1.4 (March 17, 2017) release the mssql-tools package including sqlcmd, bcp are included in the image. You can connect to the SQL Server using the sqlcmd tool inside of the container by using the following command on the host:
docker exec -it <container_id|container_name> /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P <your_password>
You can also use the tools in an entrypoint.sh script to do things like create databases or logins, attach databases, import data, or other setup tasks. See this example of using an entrypoint.sh script to create a database and schema and bcp in some data.
You can connect to the SQL Server instance in the container from outside the container by using various command line and GUI tools on the host or remote computers. See the Connect and Query topic in the SQL Server on Linux documentation.
- ACCEPT_EULA confirms acceptance of the End-User Licensing Agreement.
- SA_PASSWORD is the database system administrator (userid = 'sa') password used to connect to SQL Server once the container is running.
- For issues with or questions about this image, please contact us through a GitHub issue.
Heads up everybody! :latest (CTP 1.4) now include the mssql-tools package in the image. Now you can easily use sqlcmd or bcp without having to separately install them.
I'd love to see a build with Full-Text Search optional package included.
Thank You! It Works!
I am this sqlserver image with docker-compose. I randomly get the below error.
java.lang.RuntimeException: java.sql.SQLException: Cannot create PoolableConnectionFactory (The TCP/IP connection to the host sqlserver, port 1433 has failed. Error: "Connection refused. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".)
It fixes itself after couple of restarts, but bothers me as I have to re run my failed Travis job.
Has anyone experienced the same ?
Please also add environment variables for creation of initial User + Password, so sa-user does not need to be used.
@paigeadele try to use SqlConnectionStringBuilder. Initially i put my connectionstring on appsettings.json as usual. But i didn't work. https://www.microsoft.com/en-us/sql-server/developer-get-started/csharp-ubuntu
Here's my working code.
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
builder.DataSource = "db"; // update me
builder.UserID = "sa"; // update me
builder.Password = "Passw0rd"; // update me
builder.InitialCatalog = "testdb";
I'm new to docker, so I don't know if I'm doing it right, but when I start the mssql-server-linux container with a mapped drive for config files and databases on windows, and then try to restore a database, it crashes. Is it just me?