Allow Compose to define externally accessible resources as Docker Compose services
robertlagrant opened this issue · comments
What is the problem you're trying to solve
Have Compose manage interaction with ports on the local machine, and on remote ports as well.
Describe the solution you'd like
Be able to define services that are mappings to url (including localhost) and to one or more ports on that URL. I'd like to not have to need to worry about the correct networking mode to access ports, e.g. on a locally running service.
For example, say I have a locally running Postgres on my machine. I don't want to make a Postgres Docker container, as it's inefficient and managing state with Docker can be a small mental overhead. Instead of working out the correct networking mode, I'd love to be able to say something like the following:
services:
my_app:
image: my_local_image
environment:
POSTGRES_HOSTNAME: my_local_postgres
POSTGRES_PORT: 5432
POSTGRES_USER: postgres
POSTGRES_PASS: postgres
my_local_postgres:
hostname: localhost
allowed_ports:
- 5432
Another similar use case might be in something like GitLab CI/CD, where using their services concept alongside tests running in Docker Compose is currently difficult. Being able to easily break out of Docker Compose to a local port word be helpful.
Finally, this would be great for production deployments re: security. Having a local-only network whose exits are explicitly defined would make standardisation of tooling that inspects said exits much simpler.