Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
480 views
in Technique[技术] by (71.8m points)

mssql-server-windows-express Docker container stops immediately

I'm trying to run SQL Server Express in a Docker container.

When I run docker container run -d -P my-db:v1 it immediately stops.

The Docker file:

# escape=`
FROM microsoft/mssql-server-windows-express

ENV ACCEPT_EULA="Y" `
    DATA_PATH="C:data" `
    sa_password="mypw"

VOLUME ${DATA_PATH}
WORKDIR C:folder1

When I remove the WORKDIR line at the end, the container keeps running.

When including the WORKDIR line and running the container, Docker Desktop shows:

.start : The term '.start' is not recognized as the name of a cmdlet,

function, script file, or operable program. Check the spelling of the name, or

if a path was included, verify that the path is correct and try again.

At line:1 char:76

+ ... e = 'Stop'; $ProgressPreference = 'SilentlyContinue'; .start -sa_pas ...

+ ~~~~~~~

+ CategoryInfo : ObjectNotFound: (.start:String) [], ParentConta

insErrorRecordException

+ FullyQualifiedErrorId : CommandNotFoundException

When I inspect the container, it shows the startup command which looks ok:

"Path": "powershell",
        "Args": [
            "-Command",
            "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';",
            ".\start -sa_password $env:sa_password -ACCEPT_EULA $env:ACCEPT_EULA -attach_dbs \"$env:attach_dbs\" -Verbose"
        ]
question from:https://stackoverflow.com/questions/65872273/mssql-server-windows-express-docker-container-stops-immediately

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

CMD .start requires the start.ps1 script to be in the WORKDIR directory. The source image has WORKDIR set to the root directory (C:) and the script is in that directory (C:Start.ps1).

Now that you've changed WORKDIR to C:folder1), you need either specify a new CMD in the docker file or override the value at run time. Dockerfile example:

CMD C:start.ps1 -sa_password $env:sa_password -attach_dbs "$env:attach_dbs" -Verbose

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...