-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker volume not persisting data #1411
Comments
Please see #1452, that may be the same issue as the one I am having (with a workaround) |
I don't think it is as the same. For me I can see in the mosquitto logs |
Ah this is indeed strange - I also have all kind of docker files on my server and mapping works the way you describe. Maybe you could try to map |
had a similar issue. In my case stopping and removing the container did the trick |
After struggling with things mentioned in this issue. And like those mentioned in #1452 I arrived at something that works for me: # docker-compose.yml
version: '3.7'
services:
broker:
image: eclipse-mosquitto
restart: always
ports:
- "1883:1883"
- "9001:9001"
volumes:
- type: bind
source: ./mosquitto/config/mosquitto.conf
target: /mosquitto/config/mosquitto.conf
- type: bind
source: ./mosquitto/data/
target: /var/lib/mosquitto/
And making sure on the host that I ran: sudo chown 1883:1883 ./mosquitto/data Doing all this and it seemed to work for me. |
I struggled with it too. After a lot of experimenting, I found the solution was quite simple. Just create the three directories:
Then in
The Docker Compose file then becomes:
You need to specify the config, data and log directory separately. Also note the After this, you have data persistence and logs on the host machine. |
Worked! Why does it require them to be separate mounts? |
I'm spinning the image up with compose as follows
with the following set in the config file
but although
/mosquitto/data
is indeed being written to in the container (i.e.mosquitto.db
being created there), nothing is appearing in the synced volume on the host. Inspecting the container mounts showsI can't figure it out because I'm following the same process for mounting volumes for postgres, mongo, and elasticsearch and they are all working as expected
The text was updated successfully, but these errors were encountered: