skip to Main Content

Hi guys let me as about Docker..
so I have more Docker container and I successfully to connect container to each container with same network…
but if I set a proxy connection it make my container can not connect to each other container… what must i do guys?

here is my docker-compose.yml file

version: '3.7'

services:
  membership:
    container_name: membership_service
    build:
      context: ./membership
      target: dev
    ports:
      - 6010:6010
    volumes:
      - ./membership:/app
    network_mode: simas_net

  proxy:
    container_name: nginx_proxy
    build:
      context: ./proxy
      target: dev
    ports:
      - 8000:80
    volumes:
      - ./proxy/config:/etc/nginx/conf.d
    network_mode: simas_net

and here is proxy config

~/.docker/config.json
{
  "proxies": {
    "default": {
      "httpProxy": "http://192.168.49.1:8000/",
      "httpsProxy": "http://192.168.49.1:8000/",
      "noProxy": "localhost,127.0.0.0/8"
    }
  }
}

thanks for you’re help guys

2

Answers


  1. Chosen as BEST ANSWER

    I change grpc client dial with no proxy option. it turns out about the grpc client can not connect to rpc server but rpc server can connect to each other, so I added with no proxy for rpc client dial connection and that is worked

    grpc.Dial(target, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithNoProxy())
    

  2. This is not a big problem. Your ~/.docker/config.json is configured to automatically set three proxy environment variables on starting containers.

    • http_proxy
    • https_proxy
    • no_proxy

    Now the software inside your containers seems to react to those variables (which is expected, you usually configure those settings, to have the containers use the proxy)

    In your case however it seems that your server software picks those settings up and automatically tries to connect to the other container hostname over the proxy -> which fails because the proxy is not inside the container network, therefore he’s not able to help establishing the connection.

    multiple solutions possible:

    • configure the system which can’t connect to avoid the proxy/direct connect. you might want to limit it to:
      • the service (container name) it can’t connect at the moment
      • manually add a no_proxy value with the others container name -> hope that the software will interpret it correctly (no_proxy is not standardized)
    • remove the general proxy configuration and explicitly set the env variables (http_proxy, https_proxy, no_proxy) inside your compose files for services who need this proxy for communication
    • add the container name of the target service to your noProxy config – not recommended -> needs deamon restarts everytime you run into this problem with a new container etc. might be okay, if the containers will not change in your setup.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search