Giter Site home page Giter Site logo

Comments (13)

mystygage avatar mystygage commented on May 16, 2024 5

You can create a persistent data container with the image itself.
First create the data container and with volume /var/opt/mssql:

docker create -v /var/opt/mssql --name linuxsqldata microsoft/mssql-server-linux

Then mount the volumes from this container:

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' \
    -p 1433:1433 -d \
    --volumes-from linuxsqldata \
    microsoft/mssql-server-linux

Now you can start and stop your container without losing your data. Additionally you can docker cp a backup or the *.mdf and *.ldf files into this volume.

from mssql-docker.

twright-msft avatar twright-msft commented on May 16, 2024 3

You can either create a data container as @mystygage suggested or you can use docker run -v to mount a host directory to map to the /var/opt/mssql/data directory in the container.
Example:

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' \
    -p 1433:1433 -d \
    -v /my/host/data/directory:/var/opt/mssql/data \
    microsoft/mssql-server-linux

More information:
https://docs.docker.com/engine/tutorials/dockervolumes/

We have removed the /opt/msssql/data volume for the next release of the mssql-server-linux image to avoid confusion.

from mssql-docker.

sg1970 avatar sg1970 commented on May 16, 2024 1

@twright-msft : do the same steps work for SQL Server 2016 Image for Windows Containers also ?

from mssql-docker.

Gorbush avatar Gorbush commented on May 16, 2024 1

And if i map the whole data folder - it is failing with another error - but right on start and even fails to start:

Set up SA PASSWERD
This is an evaluation version. There are [118] days left in the evaluation period.
sqlservr: Debugger.cpp:531: static void Debugger::Print(const void , unsigned int): Assertion `m_IsAttached' failed.
Capturing core dump and information for sqlservr (pid 9)...
cat: /proc/9/sched: No such file or directory
cat: core.sqlservr.9.temp/log/debug.log: No such file or directory
No journal files were found.
No journal files were found.
ls: cannot access '/var/opt/mssql/log/log/errorlog
': No such file or directory
ls: cannot access '/var/opt/mssql/log/log/exception.log': No such file or directory
ls: cannot access '/var/opt/mssql/log/log/SQLDu*.txt': No such file or directory
ls: cannot access '/var/opt/mssql/log/log/SQLDu*.mdmp': No such file or directory
Packaging core dump and information into compressed files.
Core dump and information will be written to /var/opt/mssql/log/core.sqlservr.02_15_2017_17_26_06.9 and logs in /var/opt/mssql/log/core.sqlservr.02_15_2017_17_26_06.9.log
ls: cannot access '/var/opt/mssql/log/log/system_health*': No such file or directory

from mssql-docker.

Gorbush avatar Gorbush commented on May 16, 2024 1

If i map only the data folder, i got this:
et up SA PASSWERD
This is an evaluation version. There are [118] days left in the evaluation period.
2017-02-15 17:27:32.48 Server Microsoft SQL Server vNext (CTP1.1) - 14.0.100.187 (X64)
Dec 10 2016 02:51:11
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
on Linux (Ubuntu 16.04.1 LTS)
2017-02-15 17:27:32.48 Server UTC adjustment: 0:00
2017-02-15 17:27:32.48 Server (c) Microsoft Corporation.
2017-02-15 17:27:32.48 Server All rights reserved.
2017-02-15 17:27:32.48 Server Server process ID is 4116.
2017-02-15 17:27:32.49 Server Logging SQL Server messages in file 'C:\var\opt\mssql\log\errorlog'.
2017-02-15 17:27:32.49 Server Registry startup parameters:
-d C:\var\opt\mssql\data\master.mdf
-l C:\var\opt\mssql\data\mastlog.ldf
-e C:\var\opt\mssql\log\errorlog
2017-02-15 17:27:32.51 Server Error: 17113, Severity: 16, State: 1.
2017-02-15 17:27:32.51 Server Error 87(The parameter is incorrect.) occurred while opening file 'C:\var\opt\mssql\data\master.mdf' to obtain configuration information at startup. An invalid startup option might have caused the error. Verify your startup options, and correct or remove them if necessary.
2017-02-15 17:27:32.52 Server SQL Server shutdown has been initiated

from mssql-docker.

mystygage avatar mystygage commented on May 16, 2024 1

@OpsSingular if you prefer a data volume instead of a data container, here is a gist for that:
https://gist.github.com/mystygage/b41bbfceeeb6dc8ab0f160485186061c

from mssql-docker.

mystygage avatar mystygage commented on May 16, 2024

@twright-msft sorry, forget to mention this easy way, because on macOS I have to create the data container.

from mssql-docker.

twright-msft avatar twright-msft commented on May 16, 2024

@mystygage - Good point! Using docker run -v does not currently work on Docker for Mac for the mssql-server-linux image.

from mssql-docker.

twright-msft avatar twright-msft commented on May 16, 2024

@sg1970 Yes, but see the special notes about Windows containers here:
https://docs.docker.com/engine/tutorials/dockervolumes/#/mount-a-host-directory-as-a-data-volume

from mssql-docker.

Gorbush avatar Gorbush commented on May 16, 2024

I am struggling with the following error while trying to make persistent container when attaching database: (MacOS , Docker Toolbox with VirtualBox )
2017-02-15 17:12:28.09 spid52 FCB::Open failed: Could not open file /opt/mssql/data/bidbdat.mdf for file number 0. OS error: 87(The parameter is incorrect.).

At the same time - if i open terminal from Kitematic - no issue echoing to the file...

from mssql-docker.

mystygage avatar mystygage commented on May 16, 2024

I used Docker for Mac, but I think this makes no difference with volumes. How do you create the data volume? Based on the same image like mentioned in my comment above?

from mssql-docker.

Gorbush avatar Gorbush commented on May 16, 2024

No - i used the image https://github.com/moisei/mssql-server-linux - however the only difference i see is entrypoint script

from mssql-docker.

akolnati avatar akolnati commented on May 16, 2024

@Gorbush i get the same error. Currently creating a data container as @mystygage suggested

from mssql-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.