Docker Community Forums

Share and learn in the Docker community.

Mounting named volumes and git workflow


(Cezar Halmagean) #1

Hey guys,

What’s the best way to add changes to an image (Wordpress for example) and use git to keep a history.

So for example, I have a Wordpress image and a MySQL one. I also use a named volume to persist the MySQL data. How would I customize the Wordpress site on my dev box in a way that I could commit changes to git and also have instant feedback (without having to re-build the image every time I make a change).

Thank you

(David Maze) #2

Write a Dockerfile to start from the base image and make whatever changes you need. Whenever you need to change the contents of the image (or update the base image), run docker build to rebuild it from scratch. Keep the Dockerfile and any extra files you need to add in source control.

(docker build is pretty quick, especially if you avoid doing complicated build steps from within the Dockerfile and if you can use layer caching to avoid doing things like package installations over and over.)

(Cezar Halmagean) #3

That sounds ok but I need instant feedback while developing. Take for example changing some css, you change a value and reload your browser. I don’t want to pay the penalty of having to build the image for such a small change.

(Billy Odero) #4

You should do what is called a bind-mount for the Wordpress container you are running.

It’ll look something like:

docker run --name wp -v /path/to/wp:/app --link some-sql:mysql -d wordpress

(Cezar Halmagean) #5

What about permissions. The host user is different from the container user, how will docker sort out any permission issues? Ant thoughts?

See this: