0
I am building a Docker container from an Ubuntu image using Dockerfile. I would like the container to use the mosquitto broker.
In my dockerfile, I have this:
FROM ubuntu:latest
RUN apt-get -y update && apt-get -y upgrade
RUN apt-get install -y mosquitto
CMD ["mosquitto"]
I would expect the mosquitto service to start when I run the image as a container. I tried the -d
option with the mosquitto CMD
command in dockerfile. However, when I go to top
or ps
, I do not see mosquitto as a running process. When I, from within the container shell, type mosquitto -d
, and subsequently go to top, I see mosquitto started . I also trid systemctl enable mosquitto
followed by systemctl restart mosquitto
.
Here is my Dockerfile currently:
FROM ubuntu:latest
RUN apt-get -y update && apt-get -y upgrade
RUN apt-get install -y mosquitto
CMD ["mosquitto", "-d"]
Which I then build the image from this and run it as a container.
I would expect the mosquitto broker to just start when the container does, but it does not. I am not sure why this is, based on the Docker documentation.