I have a beginner question with docker-compose. I am trying to extend py_zipkin’s yml file (https://github.com/openzipkin/zipkin/blob/master/docker/examples/docker-compose-slim.yml) to include a simple FastAPI app that I have written, unfortunately they are not able to connect to each other. FastAPI got rejected while trying to POST to zipkin container even though they are both connected to the same network with explicit links and port mapping defined in the yml file. However, I am able to connect to both of them from the host. Could you please tell me what I have done wrong? Thanks a lot
Here is the error message:
Error emitting zipkin trace. ConnectionError(MaxRetryError(“HTTPConnectionPool(host=‘127.0.0.1’, port=9411): Max retries exceeded with url: /api/v2/spans (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fce354711c0>: Failed to es tablish a new connection: [Errno 111] Connection refused '))”))
Here is the docker-compose yml:
version: ‘2.4’
services: zipkin: image: openzipkin/zipkin-slim container_name: zipkin environment: - STORAGE_TYPE=mem ports: # Port used for the Zipkin UI and HTTP Api - 9411:9411 depends_on: - storage
storage: image: busybox:1.31.0 container_name: fake_storage
myfastapi: build: . ports: - 8000:8000 links: - zipkin depends_on: - zipkin
dependencies: image: busybox:1.31.0 container_name: fake_dependencies
networks: default: name: foo_network
Here is the Dockerfile:
FROM python:3.8.5 ADD . /app WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 8000 CMD [“uvicorn”, “wsgi:app”, “–host”, “0.0.0.0”, “–port”, “8000”]