How to persist changes to boot2docker in docker-machine?

I am using docker-machine which I use to manage VM running boot2docker with virtualbox as driver. I need to mount directory to this VM. I was able to do that by adding the folder to shared folders list in settings of VM in Virtualbox Manager. Then using sudo mount -t vboxsf -o uid=1000,gid=50 <name of folder in VM settings> <folder name>. It worked & I added the command to create directory & mount without using relative address to etc/rc.local . The changes I made to VM don’t persist when I restart the VM. What do I do?

I am working on Ubuntu 14.04.

  • Docker log without new line
  • docker run -it bash -c 'Function from sourced file'
  • Restart postgres in a docker environment
  • Not able to copy file from docker container to host
  • How do I access a POST requests body from AWS API Gateway in a connected ECS docker image
  • DockerHub and GitHub similarities
  • Dockerfile volume: local changes are not reflected in docker
  • How to parse a simple array with ng-admin
  • Why is Play application not able to resolve dependencies from inside docker container?
  • Docker mysql instant exit
  • How to properly configure the DNS configuration of the VirtualBox to resolve docker containers hostnames within the local network?
  • Symfony cannot connect to mysql DB on docker ECS container
  • 2 Solutions collect form web for “How to persist changes to boot2docker in docker-machine?”

    Create a folder. Inside, create a Dockerfile. The first line should be FROM plus the name of the image which you currently use.

    Then you can add the commands to modify the base image. In your case, put a copy of rc.local in the same folder as the Dockerfile

    Now you can copy it into your new image with:

    ADD rc.local /etc
    

    You can then build your new image with docker build -t user1932582/myapp .

    That creates a new image which you can run with docker run user1932582/myapp

    Related:

    The persistent directories are documented here: https://github.com/boot2docker/boot2docker/blob/master/doc/FAQ.md#local-customisation-with-persistent-partition

    So you can add your mount command to bootlocal.sh under /var/lib/boot2docker/ directory.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.