I am completely new in the subject of EMQX but I am trying
I installed EMQX as docker compose but I am missing something - the configuration only is ok until I make command: docker compose rm emqx
But all volumes are on my persistent storage? So why?
here is my compose file:
Hi, @zyghom. I’m not sure whether I fully understand what you mean. I think you may be unable to start EMQX because there is no configuration file in /srv/docker/emqx/etc. This is because the container will replace its original directory with the contents of the host directory after mounting.
So you need to start the EMQX container in a non-persistent way first, and then use docker cp command to copy /opt/emqx/etc/emqx.conf to your host machine.
thank you @Maverick , this I did already by using this helper - full compose file looks like this:
init-emqx:
image: emqx/emqx:latest
container_name: init-emqx
entrypoint: sh -c
volumes:
# We mount this in the container as `/emqx_etc` to not conflict with built-in files
# at `/opt/emqx/emqx_etc`
- /srv/docker/emqx/etc:/emqx_etc
command:
# Seed the files from the image to our /emqx_etc if marker file not present, skip
# if the marker file exists (and implicitly exit cleanly with status code 0)
- |
if [ ! -f /emqx_etc/.emqx-seed-complete ]; then
mkdir /emqx_etc ;
touch /emqx_etc/.emqx-seed-complete ;
cp -dpR /opt/emqx/etc/* /emqx_etc/ ;
fi
emqx:
image: emqx/emqx:latest
container_name: emqx
restart: unless-stopped
depends_on:
init-emqx:
condition: service_completed_successfully
ports:
- 1883:1883
- 8083:8083
- 8084:8084
- 8883:8883
- 18083:18083
volumes:
- /srv/docker/emqx/data:/opt/emqx/data
- /srv/docker/emqx/log:/opt/emqx/log
- /srv/docker/emqx/etc:/opt/emqx/etc
but my problem is: when I remove container by “docker compose rm emqx” I expect my next start to be with my config: users, passwords etc.
but it is not - why?
I don’t have such problems with other apps: influxdb, grafana, even mosquitto
This is because the IP of the container has changed after restarting, so its storage path has also changed.
We list solutions in FAQ, you can look at this question: Why does restarting the EMQX Docker container cause data loss, such as configured rules and resources?
perfect - thank you
could you however translate this docker command line to the entries in docker compose file please?
I am not sure how to tackle it
if you could of course