docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.89k stars 5.21k forks source link

Automatically add containers to no_proxy #11433

Open krakhead22 opened 9 months ago

krakhead22 commented 9 months ago

Description

When working with a proxy configured in docker config.json it automatically passes the proxy information to the created containers. The problem is that some projects using docker compose refer to containers via their hostname. With a proxy configured these connections can be sent to the proxy server rather than the expected container.

Since coordinating between multiple containers is most likely to occur within a compose project, and compose should be able to determine which containers are networked it would be nice if entries were automatically added to the NO_PROXY environment variables within the containers.

An example project where I encountered this behavior is https://github.com/ckan/ckan-docker which builds & runs fine out of the box on a non-proxied connection, but when a proxy is enabled ckan can't reach solr. I was able to add a few lines to the startup scripts to get past my issue, but it seems like a universal solution is feasible and would be better.

ndeloof commented 8 months ago

Within a compose application you access other services using service alias, don't you? So you can just configure your compose file with environment set to declare NO_PROXY accordingly:

services:
  db: 
    (...)
  app:
    image: backend
    environment:
      - NO_PROXY=db
krakhead22 commented 8 months ago

You are correct, adding the environment variable to the compose file solves the problem for this instance, but my point is that it would be nice if projects could work on proxy connection without having to modify the compose files (assuming the proxy was configured with docker). Docker provides a mechanism to populate proxy information to containers automatically, it would be nice if compose could complete the job so the user doesn't have to override/augment the NO_PROXY variable.

ja-pavi commented 6 months ago

Hi I'm a UT Austin student, and would like to work on this issue if possible!