-
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 image: how to config the volumes for data persistency #2780
Comments
Firstly, it looks like your configuration is at You could try create a folder somewhere named mosquitto and have a structure like:
then run something like What exactly did happen when you run |
EDIT: Similar to database images, when using the official Microsoft SQL Server image, for instance, one can use If I do |
I think this behavior comes from the VOLUME directive in Dockerfiles.
The fact that the 2 random volumes are created anyway, makes me think that they are also automatically mounted on their given paths in the container. Your data probably will end up in the random volumes too, even though you mount the parent path |
The two random volumes will be created due to the two VOLUMES, which are specified in the Mosquitto docker image (see README.md. |
I just tested this, and at least on linux, my guess were correct;
as for a "clean" way, i usually avoid the volume directive as they tend to litter a lot for my use-cases. Obviously, the mosquitto container does a little bit of "fixing" before starting the mosquitto broker, like changing permissions on the database etc, and changing these paths or config parameters is probably going to cause you more issues than it solves in most cases with the standard eclipse-mosquitto container. If you want to use the standard eclipse-mosquitto container you probably need to mount both volumes somewhere. |
Feel free to close the issue if there is nothing else :) |
I'm learning the Docker technology and I would like to map a volume for data persistency. I understood the standard image of Mosquitto binds mount the config file directly and then maps also two subfolders for the log and data.
What I would like to do is to mount just a volume, e.g. "\mosquitto" into the image at "\mosquitto" and let the application creates its subfolders and files (and copy my config file later, if needed). At the moment when I run the image like suggested, instead, it creates three volumes. What can I do to use just one volume?
What I am using:
docker run -d --network mynetwork --network-alias mosquitto --name mosquitto -p 1883:1883 -v "C:\myWindowsPath\mosquitto.conf":/mosquitto/config/mosquitto.conf -v /mosquitto/data -v /mosquitto/log eclipse-mosquitto
What I tried:
docker run -d --network mynetwork --network-alias mosquitto --name mosquitto -p 1883:1883 -v mosquitto:/mosquitto
The text was updated successfully, but these errors were encountered: