I’d like some suggestions in using Docker as a Persistent Development Environment for various projects. Now I know chroots with schroot may be the more traditionally appropriate for this use case, but the majority of the projects I use are already well integrated into docker ecosystem, and I’m already more familiar with Docker CLI. I’d also like to be able to move or connect my dev environment around with docker’s virtual networking and all, so some service I tinker with won’t collide with my local network.
Currently I have a shell alias that launches the container and mounts all my workspaces/devices and such, located on my host. However, if I ever need to install some new small dev tool during the session, I end up a needing to remember to tack it onto the dockerfile build, or commit the container to a new image layer. In either case I end up a bunch of orphaned layers, or a monolithic image I have to collapse every once in a while.
Are there any convenient/appropriate ways of mounting a whole root system into a container? I see the docker-brew-ubuntu-core/update.sh used for the official ubuntu image goes about something similar when building the image. However, I’d like start from an existing docker image rather than from starch image plus a root.tar.gz.
I was thinking of something like this:
- Starting a dummy container with the desired image,
docker exportto generate a .tar file from the container
- Extract the .tar to say a workspaces folder where I’d like to keep the persistent dev environment
- Start a new container from the same image but with the extracted tar folder mounted as
/in the container
docker run -it -v /workspaces/trusty:/ ubuntu
This although results in the flowing error:
docker: Error response from daemon: Invalid bind mount spec " /workspaces/trusty:/": Invalid specification: destination can't be '/' in ' /workspaces/trusty:/'.
I found a docker issue talking about a reciprocal of my needs, but I’m looking to mount in a
/ file system for the container, not the
/ from my host. Any suggestions to go about this with docker?