Unable to install a package using Docker(SQL server) on Mac OS X 10.13.3

Hello,

I have a Mac OS X application which I want to install. I am having database(.bak file) of approx 9 Gb and I am using .tar file installing/loading SQL server. I am using Docker to load sql server and copy .bak file into docker container and after then converting bak file into mdf and ldf. I am using developer edition for SQL server.
The issue I am facing is it is not loading sql server for 10.13.3 OS X

MY_PATH_SOURCE_DIRECTORY is source folder path
docker stop container
SERVER_FILE="$MY_PATH_SOURCE_DIRECTORY/server.tar"
docker rm container
docker load -i “$SERVER_FILE”

Attached is the screenshot for the reference.

Regards,
Itesh Dutt

sorry, i don’t understand what you are doing, and the errors are from docker build…

add --rm to the docker rum if you are going to remove the container after it ends anyhow… save a step…

i would NOT copy the data into the image… just map (-v) a local folder into a container folder where the utilities run to convert and import it into the database

can u show the dockerfile?

Hello,

I am removing the container in my previous commands.
Basically I am loading large bak file(9 GB) into docker container and it is not loading or initializing SQL server(server.tar executable file) on latest OS X version.
Can you please tell me regarding this “can u show the dockerfile?” Or are you referring to the version of docker?

I am new on this one as I have not used docker before. What is a docker file?

Regards,
Itesh Dutt

Hello,

Please find below the output from Terminal and commands which I have used to execute.

  1. Command File
    docker stop container
    SERVER_FILE="$MY_PATH_SOURCE_DIRECTORY/server.tar"
    docker rm container
    docker load -i “$SERVER_FILE”

Terminal
Error: No such container: container
Loading sql server…………….
833649a3e04c: Loading layer 115.5MB/115.5MB
a6a01ad8b53f: Loading layer 15.87kB/15.87kB
d2bb1fc88136: Loading layer 14.85kB/14.85kB
2bbb3cec611d: Loading layer 5.632kB/5.632kB
8600ee70176b: Loading layer 3.072kB/3.072kB
96fa183b2bb2: Loading layer 17.22MB/17.22MB
414af8798cbc: Loading layer 29.18kB/29.18kB
6afc71d01031: Loading layer 3.584kB/3.584kB
2fd4d3da17eb: Loading layer 64.58MB/64.58MB
14d33a424fd9: Loading layer 5.632kB/5.632kB
487e2c0ddc59: Loading layer 14.46MB/14.46MB
898f1614d8c4: Loading layer 1.682MB/1.682MB
ec68a56b0a8d: Loading layer 3.072kB/3.072kB
d6d1bf3b7183: Loading layer 580.1kB/580.1kB
c54c78fb4878: Loading layer 1.049GB/1.049GB
c0f0739ad629: Loading layer 581.7MB/581.7MB
Loaded image: server:latest

  1. Command File
    docker run -d --name container -e ‘ACCEPT_EULA=Y’ -e ‘SA_PASSWORD=P@55w0rd’ -e ‘MSSQL_PID=Developer’ -p 1433:1433 server

Terminal
b0d0a380df555ef3030400330b1c4452ed285d8ad4d17aa4c11bb61e1edc403e

  1. Command File
    sudo docker exec -it container mkdir /var/opt/mssql/containerBak

docker cp “$ABSOLUTE_PATH_SQL_FOLDER” container:/var/opt/mssql/containerBak

docker exec container /opt/mssql-tools/bin/sqlcmd -U sa -P P@55w0rd -Q "RESTORE DATABASE [DBNAME] FROM DISK=’$MSSQL_PATH_NAME’ WITH MOVE ‘DBNAME’ TO ‘/var/opt/mssql/data/DBNAME.mdf’, MOVE ‘DBNAME_log’ TO ‘/var/opt/mssql/data/DBNAME_log.ldf’ "

Terminal

Error response from daemon: Container b0d0a380df555ef3030400330b1c4452ed285d8ad4d17aa4c11bb61e1edc403e is not running

Regards,
Itesh Dutt

what is ‘server’… did u make a special image?

it is possible that something happened and the containers single process stopped executing…

if you do

docker logs container (container name or id)

is anything shown?
if you do

docker inspect sever (the image name)

you will find the entrypoint definition to see that program is supposed to be running when the container starts

Hello,

SERVER_FILE="$MY_PATH_SOURCE_DIRECTORY/server.tar"
docker load -i “$SERVER_FILE”
docker run -d --name container -e ‘ACCEPT_EULA=Y’ -e ‘SA_PASSWORD=P@55w0rd’ -e ‘MSSQL_PID=Developer’ -p 1433:1433 server

I am using server.tar image/binary file.
This issue works fine on other Mac OS X. I have tried it on 10.12.5,10.12.6 OS X.

  1. docker logs container (container name or id)
    docker logs 8f03e5816e5ed5ade045242721c0d2a4c6490519bdbf50d21384dc1b4f9568db
    Dump collecting thread [7] hit exception [6]. Exiting.

  2. GAs-MacBook-Pro:~ ga$ docker inspect /Users/ga/Documents/Desktop/IteshTestJKLawsPackage/9\ GB/server.tar
    []
    Error response from daemon: no such image: Users/ga/Documents/Desktop/IteshTestJKLawsPackage/9 GB/server.tar: invalid reference format: repository name must be lowercase
    GAs-MacBook-Pro:~ ga$ cd /Users/ga/Documents/Desktop/IteshTestJKLawsPackage/9\ GB
    GAs-MacBook-Pro:9 GB ga$ docker inspect server.tar
    []
    Error: No such object: server.tar

Regards,
Itesh Dutt

when that completes there should be a new image created. the name of the image is what was defined when the tar was created.

then you would

docker inspect server

which is the name of the image
or

docker inspect container

which is the name of the container u started

docker inspect server.tar

you do not inspect the FILE, but the image created from the file.

but the error is

Dump collecting thread [7] hit exception [6]. Exiting.

in the docker log from the db import
i don’t know where in mysql you look for

source db_backup.dump;. 

restore problem

Hello,

Let me elaborate the problem from the start:

Firstly the problem is OS X specific 10.13.3. For previous versions including (10.11 , 10.12 and upto 10.13.2 it is working fine)

I am using following docker file to create an image.
Below is the docker file content

mssql-agent-fts-ha-tools

Maintainers: Microsoft Corporation (twright-msft on GitHub)

Base OS layer: Latest Ubuntu LTS

FROM ubuntu:16.04

apt-get and system utilities

RUN apt-get update && apt-get install -y
curl apt-transport-https debconf-utils
&& rm -rf /var/lib/apt/lists/*

adding custom MS repository

RUN curl https(Please remove space in order to make link)://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https (Please remove space in order to make link)://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

install SQL Server drivers and tools

RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql mssql-tools
RUN echo ‘export PATH="$PATH:/opt/mssql-tools/bin"’ >> ~/.bashrc
RUN /bin/bash -c “source ~/.bashrc”

RUN apt-get -y install locales
RUN locale-gen en_US.UTF-8
RUN update-locale LANG=en_US.UTF-8

CMD /bin/bash

#Install curl since it is needed to get repo config

Get official Microsoft repository configuration

RUN export DEBIAN_FRONTEND=noninteractive &&
apt-get update &&
apt-get install -y curl &&
apt-get install apt-transport-https &&
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - &&
curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list | tee /etc/apt/sources.list.d/mssql-server.list &&
apt-get update

Install SQL Server which a prerequisite for the optional packages below.

RUN apt-get install -y mssql-server

Install optional packages. Comment out the ones you don’t need

RUN apt-get install -y mssql-server-agent

RUN apt-get install -y mssql-server-ha

RUN apt-get install -y mssql-server-fts

Run SQL Server process

CMD /opt/mssql/bin/sqlservr


#These commands are used to build the image from docker file.
cd /Users/paramvir/Desktop/docker-mssql-server-linux-with-fts-master
docker build -t mssqlimagefIle .

Below command is used for saving the newly created to specific folder

docker save mssqlimagefIle -o /Users/paramvir/Desktop/Image/mssqlimagefIle.tar

SERVER_FILE is the path of newly created image file

docker load -i “$SERVER_FILE”

#Creating container
docker run -d --name container -e ‘ACCEPT_EULA=Y’ -e ‘SA_PASSWORD=P@55w0rd’ -e ‘MSSQL_PID=Developer’ -p 1433:1433 mssqlimagefIle

When we are running creating container command, it creates the container but it exits automatically within no time and when we check the status of the container using docker ps -a command, it shows container exited with status 255.

We have tried the same approach using docker edge version and it is working fine for small size data base files. Not sure if it has do anything with it.

My next step after this works is to run these 3 below mentioned commands

sudo docker exec -it container mkdir /var/opt/mssql/containerBak

MSSQL_PATH_NAME="/var/opt/mssql/containerBak/$DATABASE_BAK_FILE_NAME"

ABSOLUTE_PATH_SQL_FOLDER=""$MY_PATH_SOURCE_DIRECTORY"/"$DATABASE_BAK_FILE_NAME""

BAK_FILE="$MY_PATH_SOURCE_DIRECTORY"

docker cp “$ABSOLUTE_PATH_SQL_FOLDER” container:/var/opt/mssql/containerBak

docker exec container /opt/mssql-tools/bin/sqlcmd -U sa -P P@55w0rd -Q "RESTORE DATABASE [DBName] FROM DISK=’$MSSQL_PATH_NAME’ WITH MOVE ‘DBName’ TO ‘/var/opt/mssql/data/DBName.mdf’, MOVE ‘DBName_log’ TO ‘/var/opt/mssql/data/DBName_log.ldf’ "

Please remove the spaces before https link. I have mentioned the same in the docker file content.

Thanks
Itesh Dutt

ok… the issue is to find out why the image run command for sqlserver failed.
the cmd or entrypoint command process MUST stay running, IN THE FOREGROUND, or the container will end.
if u start it in the background, the foreground shell will end and the container will end.

Hi,

I am using MyFileName.command file for that. I simply double click the file and all the commands are executed one by one. How can I force it or make it run on FOREGROUND so the container will not end?

Briefly, in that I am installing Mac OS X application(sort of like an automated package) along with its prerequisites.

Regards,
Itesh Dutt

i don’t see any mechanism to get the sqlserver command to run in the foreground…

so you will have to come up with some other process

you could create a little script which sleeps and loops…

#!/bin/sh
# sleep for a day at a time.
while true; do
    sleep 86400
done

and do that last…

u could also use one of the existing images on dockerhub

microsoft/mssql-server-linux

whose CMD is

"Cmd": [
                "/bin/sh",
                "-c",
                "/opt/mssql/bin/sqlservr"]

note that this is a nice trick…

it runs /bin/sh, in single command mode -c, which will wait for the started thing to end, and then starts sqlserver… which never ends…

ps I found this out by

docker pull microsoft/mssql-server-linux
docker inspect microsoft/mssql-server-linux

and looked at its CMD definition from its dockerfile

Hello,

I am using image file as I need some features (in the mac app which I am installing) like one of them is free text search which I am not getting when I use this command.

docker pull microsoft/mssql-server-linux

The issue for foreground or any other issue is not coming on other OS X versions. This only happens in 10.13.3

Regards,
Itesh Dutt