I am trying to run MSSQL-Server in Ubuntu 20.04 base image. Image gets created with no errors, but container does not start. Please help. Thanks in advance for your comments and helps. This is the files.
rams/ubuntu:base Dockerfile
# Use the official Ubuntu 20.04 as base image
FROM ubuntu:20.04
# Install dependencies
RUN apt-get update &&
apt-get install -y
curl
wget
software-properties-common
dirmngr
apt-transport-https
lsb-release
ca-certificates &&
apt-get clean &&
rm -rf /var/lib/apt/lists/*
Dockerfile
# Use the official Ubuntu 20.04 as base image
FROM rams/ubuntu:base
ENV DEBIAN_FRONTEND=noninteractive
# Install dependencies
RUN apt-get update &&
apt-get install -y gnupg2 &&
apt-get clean
# Install MSSQL Server and command-line tools
RUN curl https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.asc
RUN add-apt-repository "$(curl -sSL https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2022.list)"
RUN apt-get update &&
ACCEPT_EULA=Y apt-get install -y mssql-server &&
apt-get clean
RUN curl https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.asc
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | tee /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update &&
ACCEPT_EULA=Y apt-get install -y msodbcsql17 &&
ACCEPT_EULA=Y apt-get install -y mssql-tools &&
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc &&
# source ~/.bashrc &&
apt-get install -y unixodbc-dev &&
apt-get clean
# Expose the port for SQL Server
EXPOSE 1433
docker-compose.yaml
version: '3.8'
services:
sql_server:
build:
context: .
dockerfile: Dockerfile
image: rams/mssql:base
container_name: rams-mssql
ports:
- "1433:1433"
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: "YourStrong!Passw0rd"
MSSQL_PID: "Developer"
I checked the code with ChatGPT but not working.
2
Answers
Since I could not find a fix. I used the following files to fix my situation.
docker-compose.yaml
dockerfile
As mentioned in the comments you need to switch the container user and specify an
ENTRYPOINT
. You could try something like this Dockerfile…