At SQL Saturday Holland a few weeks ago I was (surprise, surprise) chatting about containers and mentioned that I hadn’t been able to get the SQL Agent working.
Jan said that he had gotten the SQL Agent running in Linux containers so I asked if he could send on his code and he very kindly obliged.
So, the disclaimer for this blog post is that I didn’t write the code here, Jan did. All I’ve done is drop it into a dockerfile so that an image can be built. Thank you very much Jan!
Here’s the dockerfile to build an image with the Agent installed: –
# specify the image with sql server installed FROM microsoft/mssql-server-linux:latest # accept the EULA ENV ACCEPT_EULA=Y # install curl & sudo RUN apt-get update && apt-get install -y curl sudo # Import the public repository GPG keys RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - # Register the Microsoft SQL Server Ubuntu repository RUN curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list # update package list RUN apt-get update -y # install the agent RUN apt-get install -y mssql-server-agent
N.B. – This dockerfile is also available on my Github
Ok, so I then dropped this docker into C:\docker\builds\linuxwithagent and built the image: –
docker build -t linuxwithagent C:\docker\builds\linuxwithagent
This does throw a few errors but will successfully build an image. A container can then be run: –
docker run -d -p 15789:1433 --env SA_PASSWORD=Testing11@@ --name testcontainer linuxwithagent
Once the container is running, connect via SSMS and the agent will be available.
I’ve made this image available on the docker hub. You can pull it down by running: –
docker pull dbafromthecold/sqlserverlinuxagent:2017-GA
Thanks for reading!