December 3, 201510 yr I'm beginning my efforts to try out making my own docker, and I don't know where to look for an answer - how do you "force" the use of /config for configuration or dynamic data in a docker container? So far when I make configuration changes inside an application and later edit the template, it refreshes my configuration away. I understand why it does that - no concerns there - but is there a docker container how-to that would include anything like this, maybe the advanced one I've seen JonP reference but I can't find? Or, is it completely application-dependent on where it can save configuration to? I've also read through here https://docs.docker.com/engine/userguide/dockervolumes/ but that seems to be all about mapping volumes in, nothing about getting data to write to them. right? This is the piece I'm struggling with: This command mounts the host directory, /src/webapp, into the container at /opt/webapp. If the path /opt/webapp already exists inside the container’s image, the /src/webapp mount overlays but does not remove the pre-existing content. I've tried mapping /config into where I think the application is making configuration changes, but it's not doing me any good. Can somebody help straighten me out?
December 3, 201510 yr Community Expert Depends on the application whether it uses a folder actually named /config. Wherever the app stores its "working files" that need to be retained from one run to the next needs to be mapped to the host. Possibly more than one folder would be involved, and none of them would necessarily be named /config. Several of the dockers around here may be applications with /config folders, but that is not really a necessary requirement for a docker generally.
December 3, 201510 yr Author Ok, let's make it more generic. Instead of /config specifically - how do you get "working files" to go to /mnt/cache/appdata/<appname>? Does that still become an application-specific question?
December 4, 201510 yr Community Expert Ok, let's make it more generic. Instead of /config specifically - how do you get "working files" to go to /mnt/cache/appdata/<appname>? Does that still become an application-specific question? Not sure I understand what you are trying to get at. I assumed you were already using dockers if you have decided to roll your own. Volume mapping is how you tell docker what container volume maps to what host path. Are you asking how you define container volumes in the dockerfile? With the VOLUME statement. Dockerfile reference. Are you asking how you know which folders in the app need to be a container volume? That is application specific.
December 4, 201510 yr You could setup the application to use the /config to store data. For example, here is the line that starts transmission, exec /sbin/setuser nobody /usr/bin/transmission-daemon -f --config-dir /config --log-info or SickBeard exec /sbin/setuser nobody python /opt/sickbeard/SickBeard.py --datadir=/config Get to the source repository of the Docker on Github and look there for some hints in the files there. Just looking at the dockerfile won't make it clear since there are scripts and such on Github that are part of the docker. For example, the SickBeard docker consists of the dockerfile and 2 scripts.
December 4, 201510 yr Author trurl - I do know what volume mapping is and how to define them - it's how to know what folders need to be a container volume, which as you say is an application question. lionelhutz - the docker that I'm looking at is jmar71n/freepbx. The primary part that I'm working on the config is the mysql DB - it's where all the freepbx configuration is stored. I will research this from an application perspective on how to change the data location. Thanks for the tips guys.
December 4, 201510 yr trurl - I do know what volume mapping is and how to define them - it's how to know what folders need to be a container volume, which as you say is an application question. lionelhutz - the docker that I'm looking at is jmar71n/freepbx. The primary part that I'm working on the config is the mysql DB - it's where all the freepbx configuration is stored. I will research this from an application perspective on how to change the data location. Thanks for the tips guys. The easiest approach with a docker is often to let the application use its standard defaults for folders; find out what these defaults are; and then use volume mapping in the container configuration to place them at sensible locations outside the container.
December 4, 201510 yr Author Yeah, I've figured that out - but am I correct that if the docker image already has data in the folder when it is pulled, it won't write new data to the mapped volume? That's the overlay that I was trying to figure out on the docker site.
December 13, 201510 yr I am watching this with interest as I too would like to run a docker with FreePBX so I can shut down and redeploy a Raspberry PI. This application seems to have defeated everyone here 'cos despite all the requests it hasn't been done. I think the database aspect ought to be the simple bit to fix especially as I think (at least originally) the config came from config files run at startup? The more difficult part would surely be the add on modules (I'll call them plug-ins for want of the right terminology). Not only are these a user choice but are also individually updateable. In fact the whole structure here is very similar to unRaid and its plugin system? I'll happily help test out anythng you produce as I think I do have some working knowledge of FreePBX and I do have a working system on my Pi which I can compare to? What I can't do is help with Docker setups as unless they work, the best I can do is complain that they don't! Sounds negative I know but its a 'black art' for which only the results are the valuable bit to me.
December 15, 201510 yr Author The challenge that I'm having is that the build process creates the database, so it's already in the image when the redirection takes place. As near as I can tell, since the file is already there, it doesn't recreate it when I map a path in. I haven't been able to figure out how to resolve this - I'm not a strong linux guy - so I'm going with the option of using the backup module in freepbx to do a full scheduled export to the mapped volume. All the modules will just be part of the image. That part seems to be working fine - even with one of the pre-existing dockers. The issue is networking. The dockers I've seen use host networking. In order to bridge it, we'd need to map ports 80, 5061, and a range of 10000-20000 (by default) for the RTP media stream. That's too complicated, so we're back to host networking. The only conflict is the port 80 for the administration. I know where to change the listener (apache) for a different port, the thing I can't seem to grasp is basic linux. What I'd like to do is specify a variable in the advanced docker for a port, and then some code somewhere would read that variable, reset the proper file and restart apache. As I said, I'm not a linux guy - how can I make a script run on startup of the docker to do this? Does it go into the image itself, or is it part of the docker script? Appreciate the help..
December 16, 201510 yr From the little bit I understand, I think you can use a script that is run after the docker starts and the script then installs the app and/or starts it after the volumes are mapped. For example, you check if the volume has the file and if it doesn't you first copy it to the volume and then symbolic link it. Otherwise, you just symbolic link it.
December 16, 201510 yr Author I know what the script needs to do - I just can't figure out where to put the script and how to call it to run... Been busy at work - with Christmas coming I'm hoping to get this resolved by the end of the year..
Archived
This topic is now archived and is closed to further replies.