Converting an SQL Server 2019 Ubuntu image to Alpine

Hi I want to host my SQL Server image on AWS Elastic Container Registry but want to make it smaller than this huge Ubuntu bloated image by converting the image to Alpine to save some dinero. It’s more than 1GB right now on Ubuntu. I’m doing this on Powershell, windows 10.

The problem is Microsoft doesn’t support it..

And yes I tried using Mssql Tools and had no success.

I will probably have to end up using Ubuntu but if anyone knows how to use Alpine for this use case then please let me know what I can do. Basically, if I run the container I built it doesn’t start.

So I first run this command to build the image.

docker build -t img_pitcher8_alpine .

Then this command to create the container:

docker run -d -p 1440:1444 --name contai_pitcher8_sql_server_alpine img_pitcher8_alpine

I cannot find any logs for the container in Docker Desktop if I run:

docker logs contai_pitcher8_sql_server_alpine

If it helps this is the docker file with the password omitted.

# Use as the base image
FROM as base

# Set environment variables

# Copy database files into image
COPY ./Pitcher8.mdf /var/opt/mssql/data/Pitcher8.mdf
COPY ./Pitcher8_log.ldf /var/opt/mssql/data/Pitcher8_log.ldf

# Start a new stage with Alpine Linux as the base image
FROM alpine

# Install necessary dependencies
RUN apk add --no-cache openssl libintl icu

# Copy files from base into current image
COPY --from=base /opt/microsoft/ /opt/microsoft/
COPY --from=base /opt/mssql-tools/ /opt/mssql-tools/

# Set up volume for database data
VOLUME /var/opt/mssql/data

# Expose port 1444 inside the container

I bound it to 1444 as I already have a container on port 1433 and want to avoid conflicts.

What are you trying to achieve?

Why do you modify the original server image? Containers are for separation, usually you try to keep things separate and not stuff it all into one container. Not copy database data into the image but mount it from host folder or volume.

SQL Server is a product that is packaged by MS, I would expect that they have already optimized it.

Why do you think it would run on alpine when it is build on Ubuntu? Both is Linux, but the underlying libraries are a bit different, so this might never work.

If you really want to change the underlying OS image, then I would rather go with an Ubuntu slim variant.

But I recommend to re-evaluate your approach.