0

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

1 Answer 1

3

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"
Sign up to request clarification or add additional context in comments.

4 Comments

can I access that from the umbraco web?
I don't know what that is
it's the part above in the docker- compose, basically just a website: web: image: ${DOCKER_REGISTRY-}umbracoapp build: context: .\umbracoapp dockerfile: Dockerfile ports: - "8000:80" depends_on: - db
You are able to reach the database from the umbraco service even without exposing the port, since the umbraco service and the database are on the same Docker bridge network. You just need to use db as the name for the database server in your umbraco configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.