mssql-docker icon indicating copy to clipboard operation
mssql-docker copied to clipboard

Docker images stop working after OS restart

Open RobertoPrevato opened this issue 4 years ago • 12 comments

Hi, I followed the instructions here: https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-ver15&pivots=cs1-bash

I started successfully SQL Server both using:

  • mcr.microsoft.com/mssql/server:2019-CU3-ubuntu-18.04
  • mcr.microsoft.com/mssql/server:2017-latest

Inside an Ubuntu 18.04 virtual machine running in VirtualBox. I could connect to the SQL Server inside a container both using sqlcmd and SQL Server Management Studio, and I even created a database using EF Core migrations without any problem (from the host where VirtualBox is running, Windows 10).

However, to my great surprise, the Docker images stop working after an OS restart of my Ubuntu 18.04 vm.

Note that I am using --rm parameter when starting the containers, so they are removed automatically on stop.

Using the images after an OS restart fails with this message:

/opt/mssql/bin/sqlservr: The file archive [/opt/mssql/lib/sqlservr.sfp] is invalid. Please resolve and try again.

$ docker run --rm -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Example@Passw0rd" -p 1433:1433 --name sql1 mcr.microsoft.com/mssql/server:2017-latest
SQL Server 2019 will run as non-root by default.
This container is running as user root.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
/opt/mssql/bin/sqlservr: The file archive [/opt/mssql/lib/sqlservr.sfp] is invalid.  Please resolve and try again.
$ docker run --rm -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Example@Passw0rd" -p 1433:1433 --name sql1 mcr.microsoft.com/mssql/server:2019-CU3-ubuntu-18.04
SQL Server 2019 will run as non-root by default.
This container is running as user mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
/opt/mssql/bin/sqlservr: The file archive [/opt/mssql/lib/sqlservr.sfp] is invalid.  Please resolve and try again.

Does someone has idea why this is happening? Shouldn't Docker images always work, if they work right after pulling them?

RobertoPrevato avatar Mar 31 '20 11:03 RobertoPrevato

I have this issue too on centos 7.8 VM running in VirtualBox Not able to resolve

Version 6.1.8 r137981 (Qt5.6.2)

DavidSpackman avatar May 20 '20 15:05 DavidSpackman

I have the same problem. I am using Microsoft SQL Server 2017 Express Edition for Ubuntu. Please share if found solution.

gadeleonp avatar Jun 22 '20 04:06 gadeleonp

Hi @DavidSpackman and @gadeleonp , no I didn't find a solution to this problem. I just resigned from using the Docker image. Quite sad that this ticket is not getting attention from Microsoft. In the past I got answers for several other issues here in GitHub.

RobertoPrevato avatar Jun 22 '20 13:06 RobertoPrevato

Hi All,

I just tried to run this on my Ubuntu machine, and was unable to reproduce this issue.

docker run --rm -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Example@Passw0rd" -p 1433:1433 --name sql1 mcr.microsoft.com/mssql/server:2019-CU3-ubuntu-18.04

Can you try again with the latest tags "2017-latest" or "2019-latest" ?

vin-yu avatar Jun 22 '20 18:06 vin-yu

Thank You! I tried again on a laptop running Ubuntu 18.04 (in this case it is not a VM running in Virtualbox), and indeed it works even after OS restart.

RobertoPrevato avatar Jun 22 '20 19:06 RobertoPrevato

@vin-yu Running the 2019-latest image does not solve the issue. After a restart of the host machine the container doesn't start, instead the posted error message is shown and the process terminates. Really annoying as the issue persists even after removing and re-creating the container.

Creating mssql_1 ... done
Attaching to mssql_1
mssql_1     | SQL Server 2019 will run as non-root by default.
mssql_1     | This container is running as user mssql.
mssql_1     | Your master database file is owned by mssql.
mssql_1     | To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
mssql_1     | /opt/mssql/bin/sqlservr: The file archive [/opt/mssql/lib/sqlservr.sfp] is invalid.  Please resolve and try again.
mssql_1 exited with code 1

Anything we can do to prevent this error?

I extracted the sqlservr.sfp file and saved it to my disk. After a restart of the machine the sha1sum of the file changed it's value. I don't have any idea how this can happen.

# sha1sum sqlservr.sfp
db2a05f4801cebf1abd9c2d8b69e7410d660f907  sqlservr.sfp
(restart host virtualbox vm)
f1b678692d95cea2de1963b51ddb92723c320910  sqlservr.sfp
(tag: 2019-CU4-ubuntu-16.04)

FireEmerald avatar Jul 10 '20 06:07 FireEmerald

I have had the same error on virtualbox (no docker) for a long time. On both ubuntu 18.04 and 20.04. The last version of mssql I used without this problem on virtualbox was this one: https://packages.microsoft.com/ubuntu/16.04/mssql-server-preview/pool/main/m/mssql-server/mssql-server_15.0.1800.32-1_amd64.deb

I finally figured out today that disabling the service before shutting down the virutal machine fixed the problem (for me at least). Did several tests after running 'sudo systemctl disable mssql-server' and now I can both shutdown/start and restart the virual machine without triggering this error.

In case this helps someone else. I came across this issue before figuring it out some hours later.

mortenee avatar Nov 16 '20 14:11 mortenee

I've just started hitting this issue now

ctolkien avatar Feb 09 '22 06:02 ctolkien

I had the same problem, with an image based on mcr.microsoft.com/mssql/server:2019-latest. Restarting the container, deleting and recreating it, rebuilding my image neither worked. Solved by removing the image stored on local docker image rm mcr.microsoft.com/mssql/server:2019-latest, removing in the same way my image, and then rebuilding it. After running problem was gone.

I assume then, that the problem is that the Microsoft image stored locally was corrupted, maybe a download error, or some disk problem after.

Scot-Bernard avatar May 10 '22 20:05 Scot-Bernard

Working from deduction, if the SQL server is not shutdown gracefully - i.e, the container is just killed without a chance for SQL to cleanly exit there is a chance that some type of file corruption occurs. You must remove the image and go again.

ctolkien avatar May 10 '22 21:05 ctolkien

I follow the Quickstart: Install SQL Server and create a database on Ubuntu to build SQL Server 2019 for Linux. All are smoothly until I shutdown my VM, and start VM, the mssql-server start failure.

The main error message are :

  1. mssql-server.service: Start request repeated too quickly.
  2. /opt/mssql/bin/sqlservr: The file archive [/opt/mssql/lib/sqlservr.sfp] is invalid. Please resolve and try again.

My environment is Windows 10 Home (host) + Virtual Box 6.1.22 + Ubuntu 20.04 (guest) + SQL Server 2019 for Ubuntu

I've found the article SQL Serve 2019 on Ubuntu fails after powering off, then reinstall SQL Server 2019 ( sudo apt-get install --reinstall mssql-server ), it seems OK until I shutdown again.

I don't have any idea why it occurs. The following are the screen capture for error messages. picture_02 picture_03

jasper-lai avatar Aug 04 '22 04:08 jasper-lai