There are two ways you can do this.
One is you run SQL Server from a container. You can run it from a Linux container including:
Quickstart: Run the SQL Server 2017 container image with Docker
The configuration in your docker-compose.yml will look like this:
version: "3.4"
services:
ubuntu:
build: .
mssql-linux:
image: microsoft/mssql-server-linux
ports:
- "1433:1433"
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=MySafePassw0rd!
volumes:
- mssql-data:/var/opt/mssql/data
volumes:
mssql-data:
driver: local
The advantage of doing this is that it is easier for someone who does not have SQL Server installed on the machine to do something.
The second way is to change the network in the Docker Compose to instead of running within the NAT using the same host network
version: "3.4"
services:
ubuntu:
build: .
networks:
default:
external:
name: host
Or use the option --net=host
when running the container
docker container run --net=host minha-imagem