Esben
Esben

Reputation: 1971

Docker separation of processes and source code control

I am trying to wrap my head around an optimal structure for Dockerization of a web app. So one of the best practices recommendations for using Docker is having one process per container. So where do I put the source code of my app?

Assume I am making a simple nginx and php app. The one process per container rule suggests having a nginx container that serves static assets and proxies php requests to a php-fpm container.

Now where do I put the source code? Do I keep it in a separate container and use volumes_from in Docker compose to let the two containers access the code? Or do I build each container with the source code inside (I suppose that makes it easier with versioning)?

What are the best practices around this?

Upvotes: 2

Views: 81

Answers (1)

VonC
VonC

Reputation: 1324148

Do I keep it in a separate container and use volumes_from in Docker compose to let the two containers access the code?

That is the usual best-practice, which avoid duplicating/synchronizing codes between components.
See "Creating and mounting a data volume container".

This is not just for pure data, but also for other shared resources like libraries, as shown in this article "How to Create a Persistent Ruby Gems Container with Docker":

http://cdn.atlashealth.com/wp-content/uploads/docker-shared-gems.png

Upvotes: 2

Related Questions