Host docker network [closed]

2

I have a problem with the server, but I can not find a way to connect to it. I have a problem with this: on my local network and docker the network is only on my machine?

Example: ip of the container = 172.18.0.2 Ip of my sql server = 192.168.0.58

Remembering that I use docker on windows 10.

In case of access, do I have to put this information in my Dockerfile or docker-compose?

    
asked by anonymous 07.03.2018 / 02:05

1 answer

1

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
    
07.03.2018 / 02:46