Install Microsoft SQL Server 2017 with Docker in Ubuntu 18.04 LXD Containers

In this post, you use Docker to pull and run the SQL Server 2017 container image in Ubuntu 18.04 LXD containers. This post contains a fix for ZFS on Linux with SQL Server 2017.

Launch the Ubuntu 18.04 container from your Ubuntu LXD host:

lxc launch --profile default ubuntu:18.04 CTNAME --target host-1

Allow Security Nesting (Container in Container) and allow the aufs module inside the container:

lxc config set CTNAME security.privileged true
lxc config set CTNAME security.nesting true
lxc config set CTNAME linux.kernel_modules "aufs"

Open your container:

lxc exec CTNAME bash

Update your container and install Docker:

apt-get update apt-get upgrade -y
apt-get install -y

Enable Docker on boot:

systemctl enable docker

Change the storage driver to aufs:

nano /etc/docker/daemon.json

And paste the following config:

  "storage-driver": "aufs"

Restart Docker to apply the changes:

systemctl restart docker

The LXD Container and Docker are ready to use.

Since the release of ZFS 0.8 the fix below is no longer necessary. ZFS 0.8 supports O_DIRECT.
The fix is needed for Ubuntu 18.04. Skip Option 1 if you use ZFS version 0.8 or later on your LXD host. Issue: Github

The setup log (/var/opt/mssql/log) after the first start:

2019-05-10 09:53:25.06 Server      Error: 17113, Severity: 16, State: 1.
2019-05-10 09:53:25.08 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.

ZFS version check:

cat /sys/module/zfs/version

Option 1 (With ZFS Fix):

Install unzip:

apt-get install unzip

Download the and unzip

cd /root

Dockerfile must be lowercase:

mv /root/mssql-docker-zfs-master/Dockerfile /root/mssql-docker-zfs-master/dockerzfsmssql

Build the image:

docker build -t dockerzfsmssql /root/mssql-docker-zfs-master/

Start the SQL Server 2017 Docker container:

sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 --name sql1 -d dockerzfsmssql

Check the running container:

[email protected]:~/mssql-docker-zfs-master# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                              NAMES
d7d2ff0caab0        dockerzfsmssql      "/opt/mssql/bin/sqls…"   58 seconds ago      Up 50 seconds       1433/tcp,>1433/tcp   sql1

Option 2 (Without ZFS Fix):

Download SQL Server 2017:

sudo docker pull

Run the container image with Docker:

sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' \
   -p 1433:1433 --name sql1 \

Check the remote database connection on port 1433.
You can use Navicat for SQL Server:

You should now have a fully working Microsoft SQL 2017 Docker Container with ZFS in an Ubuntu 18.04 LXD Container!