Docker Community Forums

Share and learn in the Docker community.

Pass configuration file to mosquitto in Docker container

Trying to run masquitto Docker container on Windows. I have directory structure:

..
mosquitto
  config
     -- mosquitto.conf
  data
  log

I run command:

docker run -it -p 1883:1883 -p 9001:9001 -v mosquitto.conf:/mosquitto/config/mosquitto.conf -v /mosquitto/data -v /mosquitto/log eclipse-mosquitto

Got error:

docker: Error response from daemon: source /var/lib/docker/overlay2/c54f317f73085489398e1b2c4ffbc85fbdb18073e8a0fa60f11a7f7222fbc49d/merged/mosquitto/config/mosquitto.conf is not directory.
See 'docker run --help'.

What I do wrong?

You need to pass an absolute path to your hosts config file

Install Mosquitto
In a Docker container

docker run -it --name mosquitto1 -p 1883:1883 eclipse-mosquitto
Add --net=host if you want the container to use the same IP address as host—this is not supported in Docker for macOS and Windows.

To restart container later

docker start -ai mosquitto1
To edit config file exec command shell in container

docker exec -it mosquitto1 /bin/sh
Run vi

vi /mosquitto/config/mosquitto.conf