I have a docker-compose file that includes a service configured like:
py_publisher:
build:
context: ./client
dockerfile: Dockerfile
deploy:
mode: replicated
replicas: 3
# entrypoint: "python3 mqtt_client.py"
The image is built from this Dockerfile:
# syntax=docker/dockerfile:1
FROM python:3.8-slim-buster
WORKDIR /mqtt_client
COPY . .
RUN pip3 install -r requirements.txt
CMD ["python3", "mqtt_client.py"]
The home dir (/mqtt_client
) of the container contains:
Dockerfile mqtt_client.py requirements.txt
The relevant docker-compose results:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
61b8f5e1e0bb e1d0fc27a640 "python3 mqtt_client…" 7 seconds ago Up 2 seconds mqtt-demo_py_publisher_1
9992b9c9031d e1d0fc27a640 "python3 mqtt_client…" 7 seconds ago Up 3 seconds mqtt-demo_py_publisher_2
a197f0f3126b e1d0fc27a640 "python3 mqtt_client…" 7 seconds ago Up 2 seconds mqtt-demo_py_publisher_3
The issue is that the Python command is not actually "working". Simply nothing happens. However, when I exec
into the containers and run that exact command, it works fine.
What's the difference in the way I'm running via docker-compose and running it manually exec'ed into the container?