Yesterday I needed a php 5.6 environment. Locally I'm running 7.0. First thought was to brew install php56, unlink php7 and link php56, but this proved a bit more complex than expected.
Attempting to install php56 through brew was resulting in:
Error: /usr/local/opt/php56 is not a valid keg.
After 20 minutes of troubleshooting I decided that a more effective use of my time would be to get on the docker train.
"No problem", I thought. I'd pull any one of the thousands of docker images already setup with ubuntu or alpine and php56, add a shared volume (my source code directory), and I'm off.
I installed Docker Dommunity Edition for Mac, jumped into Kitematic, found an image that matched my requirements (thanks, jolicode), ran:
docker pull jolicode/php56
and saw it show up in Kitematic. Jumped into the container settings-> Volumes and... Nothing. There's no way to add a new volume.
Not so easy. Unless the Dockerfile has an explicitly defined VOLUME entry, Kitematic will not display any actions.
Being that I want nothing to do with creating or maintaining a Dockerfile, and instead only want to quickly piggyback on someone else's public container, I was surprised to find no easy answer to my usecase. Eventually I came across a stackoverflow with some relevant info.
For now yes, the only way is recreation. See Docker Pull Request 8484 for when we can expect the dynamic adding functionality.
You can commit your existing container then run it with your new mounts.
This is the magic I was looking for.
docker ps -a // Show list of recently run containers
docker commit <container id> <new name of container> // create a new image from a container's changes
docker run -ti -v <path to local src dir>":<path to docker mounted dir> <new name of container> /bin/bash // Run the new image with the shared volume