Service address injection to other services via environment variables
Description
In my docker compose file, I've created my services and in override file I made some configurations like ports and environments.
It'll be more convenient to show it than describing it so my docker-compose file is:
version: '3.4'
services:
frontend:
image: ${REGISTRY:-vapr}/frontend:${PLATFORM:-linux}-${TAG:-latest}
build:
context: .
dockerfile: Frontend/Dockerfile
depends_on:
- appprx
- backend1
backend1:
image: ${REGISTRY:-vapr}/backend1:${PLATFORM:-linux}-${TAG:-latest}
build:
context: .
dockerfile: Backend1/Dockerfile
appprx:
image: envoyproxy/envoy:v1.11.1
and my docker-compose.override file is:
# Please refer https://aka.ms/HTTPSinContainer on how to setup an https developer certificate for your ASP .NET Core service.
version: '3.4'
services:
frontend:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80
- Test=http://backend1
- Test2=backend1
ports:
- "5100:80"
backend1:
environment:
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "5101:80"
When I'm trying to reach the environment variable Test on frontend application, I get http://backend1
It should be http://localhost:5101/
Steps to reproduce the issue:
- Create Frontend application (In my case it's asp.net core mvc app)
- Create Backend application (In my case it's asp.net core webapi)
- Create ordinary dotnet Dockerfile for each app and expose them both on port 80
- Create docker-compose files I've shared above
- run
docker-compose up --buildetc. - Open Frontend application on browser
http://localhost:5100/ - Check Frontend applications environment variables
Describe the results you received:
Describe the results you expected:
Additional information you deem important (e.g. issue happens only occasionally):
Output of docker compose version:
docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1h 22 Sep 2020
Output of docker info:
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Build with BuildKit (Docker Inc., v0.6.3)
compose: Docker Compose (Docker Inc., v2.0.0)
scan: Docker Scan (Docker Inc., v0.8.0)
Server:
Containers: 9
Running: 5
Paused: 0
Stopped: 4
Images: 36
Server Version: 20.10.8
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
Default Runtime: runc
Init Binary: docker-init
containerd version: e25210fe30a0a703442421b0f60afac609f950a3
runc version: v1.0.1-0-g4144b63
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 5.10.47-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 21.52GiB
Name: docker-desktop
ID: NBN2:B7O3:BQKK:TRLC:3IUK:PK5L:FRXH:SLMK:7752:YQCS:52M5:E63U
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional environment details:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because it had not recent activity during the stale period.
This issue has been automatically closed because it had not recent activity during the stale period.