Hot to enable swarm containers to connect to the host machine?

I need to use docker in swarm mode to use some shared secrets through my services.

One of these services needs to use a local MS SQL database on my computer.

  • How to determine when cmds in docker exec complete
  • Unable to start jenkins auctomatically inside docker container
  • Graphite installation in a docker container - volume query
  • marathon does not delete a docker container after destroying the job
  • “I have no name!” as user logging into Jenkins in a docker container that uses Tini
  • Need some advice dockerizing MongoDB
  • This is my docker-compose file:

    version: '3.2'
    services:
        auth_service:
            build: ./Services/AuthService
            image: sandhaka/auth_service
            command: dotnet run --rm
            ports:
                - "5000:5000"
            environment:
                ASPNETCORE_URLS: http://*:5000
                DB_CONNECTION_STRING: 'Server=10.0.0.102,1433; Database=micrs-auth-db; User=sa; Password=Password'
            secrets:
                - jwt-pvt-key
                - jwt-pub-key
        resource_test_service:
            build: ./Services/ResourceTestService
            image: sandhaka/resource_test_service
            command: dotnet run --rm
            ports:
                - "9000:9000"
            environment:
                ASPNETCORE_URLS: http://*:9000
            secrets:
                - jwt-pub-key
    secrets:
        jwt-pub-key:
            file: ./keys/jwtRS256.key.pub
        jwt-pvt-key: 
            file: ./keys/jwtRS256.key
    

    The problem is that, with the swarm mode configuration, the ‘auth_service’ service is unable to connect to the host network.

    I am not a swarm expert, then my question is:
    How to configure the swarm overlay network to access a ip:port of the host?
    And also, how to expose the containers to the host, for example to debug the services ?

  • Docker port isn't accessible from host
  • How to change the default location for “docker create volume” command?
  • how I can execute scripts on docker-machine create
  • Kibana on Docker cannot connect to Elasticsearch
  • Persist users across containers
  • When would a Docker image and its repository have different names?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.