Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to persist changes in boot2docker

I'm fairly new to Docker and has stumbled on a problem that I have been unable to figure out any solutions to.

I'm on a Mac so I have to use Boot2Docker as my environment. I do all my stuff inside the VM using boot2docker ssh to mimic a "real" situation as far as possible.

My problem is that as soon as I close down boot2docker with boot2docker down or stop I loose all my changes... How can I persist my edits?

What I have done is to create some directories, /opt/sites for instance, and added some code to .profile. All is gone when I start boot2docker up again.

I have tried to put everything at /Users... as boot2docker 1.3 and upwards auto mounts that location but then I get problem using --volumes on some containers (more specifically MySQL containers...)

I think I can solve the data storage, (--volumes problem), but where do I put the definition of PATH and other environment variables?

I'm probably misunderstanding something so please point me in the right direction ;-)

like image 296
Thomas Rambrant Avatar asked Jan 14 '15 07:01

Thomas Rambrant


People also ask

How do you persist data in a container?

When you make it available to the next container, the application can pick up where it left off. By creating a volume and attaching, or mounting, it to the folder that the data is stored in, you can persist the data. The container writes to the todo. db file and that data persists to the host in the volume.

How do you save changes in containers?

Hence, if you want the changes to persist, you can use the Docker commit command. The commit command will save any changes you make to the container and create a new image layer on top of it.


1 Answers

After you make your changes to the boot2docker image, run the 'boot2docker save' command. You should see your changes persist after you restart boot2docker.

like image 78
andy.jackson Avatar answered Oct 02 '22 18:10

andy.jackson