I’ve inherited a codebase for a system. For reference this is a symfony project.
The eventual plan is to move to a microservices architecture. The microservice responds only to web requests and is using JSONAPI to transfer data.
I’ve separately developed a new microservice and on its own. It has tested and performed well. It is not feasible to take the old system offline, so the approach is to transition service by service depending on business and infrastructure needs/possibility.
There are two separate docker container sets, one for “the old system” and one for “the microservice” (and its future other services). Both have various containers including php74.
To be clear, I mean "there are two separate
docker-compose.yaml files that both are to be kept separate that both are run using
As I have two web facing container sets, I’ve mapped them as follows:
"80:80"“the old system”
These do not clash on web traffic.
The microservice does plenty, but notably it runs a “hello world, welcome to the API” style response to a index
GET request (let’s call it
Within “the old system”, I’ve mapped to the new system (I have tried both of the following methods)
networks: default: aliases: - microservice.test
as well as:
extra_hosts: - "microservice.test:127.0.0.1"
microservice.test responds on my local machine.
If I log into “the old system” php74 container, I can
ping microservice.test and this is successful.
If I run a unit test from “the old system” and use cURL to download the index request, I get a
null response. Note: if I ping or curl
google.com I get a response.
The next step is to use the provided microservices client… but the above debugging step shows the issue.
Effectively, when php attempts to access the domain
microservice.test it cannot see it.
How can I ensure that a docker container can access:
- a domain hosted on a different docker container set (different docker-compose.yaml file)
I would ideally like the web requests to fully leave one container set, then be bounced back… much like real microservices infrastructure would be (eg: possibly on different servers/hosts etc). Is this possible?
- This must use web only traffic
- php container can ping the
- cURL fails to get a response the
- cURL successfully gets a response from external urls, such as google
Thanks in advance.