Naming data containers
At the moment, data volume containers are named as a derivative of the original container name: containerName.upper() + '_DATA'
Would it be useful to optionally allow the creation and/or use of specifically named data volume containers?
I can imagine four cases:
- current default: when running
dmysql-serverto create a sever named foo, create a data volume container named foo_DATA - using a pre-existing container (1): if we have
dmysql-server --volumes-fromto create a container foo, where--volumes-fromis a flag, then link to foo_DATA; - using a pre-existing container (2): what about if we don't want to automatically generate the named of the linked data volume container? Do we need another parameter, eg
--data-volume NAMEthat runs as--volumes-from NAMEas part ofrunContainer()? In this case, should we require--volumes-from --data-volume NAME? What should happen if--volumes-fromflag is not set (that is, only--data-volume NAMEis supplied)? Or should--data-volume NAMEforce the setting of--volumes-fromas true? - creating a custom named data container: again using eg
--data-volume NAME, rather than runningcreateVolume(containerName.upper() + '_DATA')we runcreateVolume(NAME)?
If we take this approach, is --data-volume NAME sensible? Or should it be called something else? --data-volume-name NAME ?
I've been thinking about this for like 10 minutes because as you say, there are multiple scenarios.
- --volumes-from is not used so no problem here.
- --volumes-from is used and a new data-only container is created with the value FOO_DATA
- It should be possible to enter the name of the data-only container.
- It should be possible to link a pre-existing data-only container.
So I do agree, but the question is how?
As you mention, --volumes-from with no options could default to FOO_DATA. With an option, it could use the argument as the name for the container, and if the container is already created, it could just link it.
Right now, I don't know how to check if the container exists and then decide if is going to be created or just linked it, probably it will be necessary to query the Docker API to do this.
Okay, so that's yet another binary question - does a container we are trying to link to exist or not?
I've popped a revision of dmysql-server at https://github.com/psychemedia/docker-mysql-scripts but haven't submitted a pull request because I haven't had time to properly test it yet (and possibly won't have time now for a day or two). The updated README explains the usage.
I also started mulling over a script dmysql-server-rm to remove a server and any associated volumes or data volume containers so that stuff didn't start getting left all over the place.