1

I've two docker-compose files, one contains the solution with multiple API's the other contains some background running programs.

The problem is that one background program uses the API that runs in the other compose file. I was hoping I could use cotnainername as http://[CONTAINERNAME]:80 but that isn't working, the url is not known. I think it is because it's not known in that compose file? What is the solution for this case?

Below the simplified (removed the other services) docker-compose.yml's

file1:

version: '3.3'
services:
    firstapi:
        image: firstapi:latest
        container_name: firstapi
        ports:
            - "4005:80"

file2:

version: '3.3'
services:
    firsttool:
        image: firsttool:latest
        container_name: firsttool
        environment:
            - Endpoint_FirstAPI=http://firstapi:80
BvdVen
  • 2,921
  • 23
  • 33
  • 2
    Unless you specify otherwise (see https://docs.docker.com/compose/compose-file/#network-configuration-reference), each compose file will also define a separate network. Service-name-as-hostname only works within one network. – jonrsharpe Jun 06 '19 at 07:40

1 Answers1

0

create a network and use it for those two compose files.

todaynowork
  • 976
  • 8
  • 12