Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSSQL at Docker exits instantly

Tags:

sql-server

I'm trying to setup MSSQL at Docker at Windows 10, but for some reason it started shutting down my container

I've been using it like that for months, but now I have no idea what's happening

    C:\Users\user\
    λ docker ps -a
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

    C:\Users\user\
    λ docker login
    Authenticating with existing credentials...
    Login Succeeded

    C:\Users\user\
    λ docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>123' -p 1433:1433 --name sql -d mcr.microsoft.com/mssql/server:2017-latest
    337e5efb35f0bf4b465181a0f8be4851b12f353a3a8710ddf817d2f501e5fea

    C:\Users\user\
    λ docker ps -a
    CONTAINER ID        IMAGE                                        COMMAND                  CREATED             STATUS              PORTS                    NAMES
    347q5effb3cf0        mcr.microsoft.com/mssql/server:2017-latest   "/opt/mssql/bin/sqls…"   3 seconds ago       Up 2 seconds        0.0.0.0:1433->1433/tcp   sql

    C:\Users\user\
    λ docker ps -a
    CONTAINER ID        IMAGE                                        COMMAND                  CREATED             STATUS                     PORTS               NAMES
    347q5effb3cf0        mcr.microsoft.com/mssql/server:2017-latest   "/opt/mssql/bin/sqls…"   6 seconds ago       Exited (1) 2 seconds ago                       sql

    C:\Users\user\
    λ docker start sql
    sql

    C:\Users\user\
    λ docker ps -a
    CONTAINER ID        IMAGE                                        COMMAND                  CREATED             STATUS              PORTS                    NAMES
    347q5effb3cf0        mcr.microsoft.com/mssql/server:2017-latest   "/opt/mssql/bin/sqls…"   14 seconds ago      Up 2 seconds        0.0.0.0:1433->1433/tcp   sql

    C:\Users\user\
    λ docker ps -a
    CONTAINER ID        IMAGE                                        COMMAND                  CREATED             STATUS                    PORTS               NAMES
    347q5effb3cf0        mcr.microsoft.com/mssql/server:2017-latest   "/opt/mssql/bin/sqls…"   16 seconds ago      Exited (1) 1 second ago                       sql

docker logs sql

shows

The SQL Server End-User License Agreement (EULA) must be accepted before SQL Server can start. The license terms for this product can be downloaded from http://go.microsoft.com/fwlink/?LinkId=746388.

You can accept the EULA by specifying the --accept-eula command line option, setting the ACCEPT_EULA environment variable, or using the mssql-conf tool. The SQL Server End-User License Agreement (EULA) must be accepted before SQL Server can start. The license terms for this product can be downloaded from http://go.microsoft.com/fwlink/?LinkId=746388.

You can accept the EULA by specifying the --accept-eula command line option, setting the ACCEPT_EULA environment variable, or using the mssql-conf tool.

Anybody has an idea what may be wrong?

like image 472
Joelty Avatar asked Nov 29 '18 10:11

Joelty


People also ask

Why my docker run exits immediately?

Why docker container is exited immediately? You're running a shell in a container, but you haven't assigned a terminal: If you're running a container with a shell (like bash ) as the default command, then the container will exit immediately if you haven't attached an interactive terminal.

How do I stop docker from exiting?

If there's no terminal attached, then your shell process will exit, and so the container will exit. You can stop this by adding --interactive --tty (or just -it ) to your docker run ... command, which will let you type commands into the shell.

Can I run SQL Server in a docker container?

With Docker, you can also run multiple SQL Server Containers on the same host machine.

Does SQL Server in a container support persisting data?

Persist your data. Your SQL Server configuration changes and database files are persisted in the container even if you restart the container with docker stop and docker start .


1 Answers

When running Linux containers from Windows command line/Powershell, the environmental options (-e) require double quotes

docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong!Passw0rd>123" -p 1433:1433 --name sql -d mcr.microsoft.com/mssql/server:2017-latest
like image 73
Gareth Lyons Avatar answered Sep 24 '22 23:09

Gareth Lyons