I am trying to connect to my DB that has been created in my Docker Compose file. It looks like the DB has been successfully created but I am unable to connect to it using SQL Server management studio.
Here is my Docker Compose file:
version: "3.9"
services:
web:
image: ${DOCKER_REGISTRY-}umbracoapp
build:
context: .\umbracoapp
dockerfile: Dockerfile
ports:
- "8000:80"
depends_on:
- db
db:
image: "mcr.microsoft.com/mssql/server"
environment:
SA_PASSWORD: "Testing1234!!"
ACCEPT_EULA: "Y"
Thanks
CodePudding user response:
To access the database from outside the bridge network that Docker creates, you need to map it's port to a port on the host.
In the container, MSSQL uses port 1433. If that port is available on your host, you can map it to 1433 on the host by adding 'ports' to your db service like this
db:
image: "mcr.microsoft.com/mssql/server"
ports:
- "1433:1433"
environment:
SA_PASSWORD: "Testing1234!!"
ACCEPT_EULA: "Y"