Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] container names for compose from app_b -> fastapi-jaeger_app-b_1 #2

Closed
larrycai opened this issue Jul 28, 2023 · 2 comments

Comments

@larrycai
Copy link

larrycai commented Jul 28, 2023

Don't know what's the wrong with my env? I use podman-compose @ Mac, but it shall be the same.

forget how to fix it, I got the container name is fastapi-jaeger_app-a_1 with extra prefix fastapi-jaeger and suffix _1.

I have to change in all related areas to make it work as expected

  • main.py like TARGET_ONE_HOST = os.environ.get("TARGET_ONE_HOST", "fastapi-jaeger_app-b_1") // from app_b
  • docker-compose.yaml for naming
  • config under etc

But I think it shall not work like this, what's wrong with my env? I use podman-compose @ Mac, but it shall be the same

Can you paste your console out in the readme, I got it like below.

$ podman ps
CONTAINER ID  IMAGE                                                   COMMAND               CREATED         STATUS                 PORTS                                                                       NAMES
645c7459b3f8  localhost/fastapi-jaeger_app-a:latest                   uvicorn main:app ...  25 seconds ago  Up 14 seconds          0.0.0.0:8000->8000/tcp                                                      fastapi-jaeger_app-a_1
ffd1e27990ee  localhost/fastapi-jaeger_app-b:latest                   uvicorn main:app ...  24 seconds ago  Up 13 seconds          0.0.0.0:8001->8000/tcp                                                      fastapi-jaeger_app-b_1
3334db65abff  localhost/fastapi-jaeger_app-c:latest                   uvicorn main:app ...  23 seconds ago  Up 12 seconds          0.0.0.0:8002->8000/tcp                                                      fastapi-jaeger_app-c_1
08caf128b172  localhost/fastapi-jaeger_app-d:latest                   uvicorn main:app ...  21 seconds ago  Up 11 seconds          0.0.0.0:8003->8000/tcp                                                      fastapi-jaeger_app-d_1
b9c68f04cbfd  docker.io/library/cassandra:4.1.2                       cassandra -f          20 seconds ago  Up 10 seconds                                                                                      fastapi-jaeger_cassandra_1
eea4cb843e23  docker.io/jaegertracing/jaeger-cassandra-schema:1.47.0                        19 seconds ago  Up 9 seconds                                                                                       fastapi-jaeger_cassandra-schema_1
c8592793aee5  docker.io/jaegertracing/jaeger-collector:1.47.0         --cassandra.keysp...  17 seconds ago  Up Less than a second  0.0.0.0:39969->4317/tcp, 0.0.0.0:41079->4318/tcp, 0.0.0.0:39891->14250/tcp  fastapi-jaeger_jaeger-collector_1
20075f5cf1a8  docker.io/otel/opentelemetry-collector-contrib:0.81.0   --config=/conf/co...  15 seconds ago  Up 6 seconds           0.0.0.0:39077->4317/tcp, 0.0.0.0:44199->4318/tcp                            fastapi-jaeger_otel-collector_1
@blueswen
Copy link
Owner

Hi @larrycai ,

Sorry for the late reply. The container name looks correct to me, and I had put my container status in readme. There are some differences like underline or dash, but I think that just because podman compose and docker compose have different patterns to generate the container name dynamically.

Back to your main question about why the containers can't communicate with each other even though you already modified the host inmain.py when using podman compose. In docker compose, each container can communicate with each other with service name(the key in compose file's services section) because they are in the same network. So there is no need to modify the host name, just keep it with the service name.

Since I am not using podman, I can't reproduce your issue. But I think it may be related to the network type you are using for podman, there are some discussion on containers/podman-compose#541 (comment) and containers/podman-compose#455 (comment). You can try to switch your podman network from cri to netavark, then your container may communicate with each other with service name.

There is a post Podman 4.0's new network stack: What you need to know from RedHat may help you too.

@larrycai
Copy link
Author

Yes, u r correct. I checked the /etc/hosts, it actually goes via DNS.

thank

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants