Docker container for SQL Server Linux keeps exiting

Viewed 2477

I wanted to modify the behavior of container for SQL Server Linux by adding a simple database with one table as the container starts.

The docker image version where I am seeing this issue with is the latest version as of 5/20/2017 i.e. ctp2-1.

I am using Docker for Windows with the latest version at 17.05.0-ce. I increased RAM of the MobyLinuxVM to 6144MB since more than 4GB is recommended.

Steps to reproduce issue

PREPARE FILES

(1) Create a local Windows folder, in my case, 

    C:\temp\docker\

(2) Add "Dockerfile" (note no file extension) with the following content.

    FROM microsoft/mssql-server-linux:latest
    COPY ./custom /tmp
    RUN chmod +x /tmp/entrypoint.sh \
        && chmod +x /tmp/createdb.sh
    CMD /bin/bash /tmp/entrypoint.sh

(3) Add a subfolder "custom"

    C:\temp\docker\custom\

(4) Add 3 files to "custom" subfolder with following content.

   (A) entrypoint.sh
    /opt/mssql/bin/sqlservr & /tmp/createdb.sh

   (B) createdb.sh
    sleep 30s
    /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P '!StrongPass45' -d master -i /tmp/createdb.sql

   (C) createdb.sql
    CREATE DATABASE DemoData;
    GO
    USE DemoData;
    GO
    CREATE TABLE Products (ID int, ProductName nvarchar(max));
    GO

RUN DOCKER COMMANDS (YOU WILL SEE THE ISSUE AT THE LAST STEP HERE)

(1) Open PowerShell and cd to folder in step (1) above, in my case

    cd C:\temp\docker

(2) Run docker build command

    docker build .

(3) After image is built, run the following command and remember the first 3 letters of your image id, in my case "e65"

    docker images

    [![enter image description here][2]][2]

(4) Create the container with the following command (note the last 3 characters should be replaced by yours, also use the same password you used above)

    docker run -d -e SA_PASSWORD="!StrongPass45" -e ACCEPT_EULA="Y" -p 1433:1433 e65

(5) Check your container is running

    docker ps -a

  [![enter image description here][2]][2]

(6) Wait about 2 minutes and check your container status again. AT THIS POINT, THE CONTAINER WOULD HAVE EXITED.

   docker ps -a

   [![enter image description here][2]][2]

I checked the logs as follows.

docker logs e65

Attached below is the bottom part of logs right after SQL Server has successfully created the DemoData database.

[![enter image description here][2]][2]

IMO, the problem line in the logs is this one

Parallel redo is shutdown for database 'DemoData' with worker pool size [1].

I have tried various other SQL statements (even adding custom MDF and LDF files and attaching to them) to add behavior to OOB image. I have even been able to connect to the new database using SSMS for a few seconds before the container exits!

Has anyone seen this issue? Can someone give this a try?

1 Answers
Related