How do I setup a docker image to dynamically pull app code from a repository?

I’m using docker cloud at the moment. I’m trying to figure out a development to production workflow using docker with docker compose to pull application code for multiple applications of the same type, but simply changing the repository each pulls from. I understand the concept of mounting a volume, but all the examples show the source code in the same repo with the dockerfile and docker compose file. example. I want the app code from this example to come from a remote, dynamic repo. Would I set an environment variable in the docker image? If so how?
Any example or link to a workflow example is appreciated.

  • Using RQ with a Docker container hosted on Heroku
  • Docker: Could not get container for XXX
  • Reuse inherited image's CMD or ENTRYPOINT
  • Tensorflow for Poets | Relaunching Docker | invalid reference format
  • Setup global environnement variables for all Docker containers
  • Overriding `tcp.publish_port` breaks clustering when elasticsearch is in a container
  • Fatal error when running a JavaFX GUI app inside Eclipse in a Docker container
  • Running multiple time the same docker image
  • Command to Copy/share jmeter master container results (Docker) generated in by running the script in non-gui mode to EC2 instance
  • Protractor tests in Docker - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL
  • Error response from daemon: getsockopt: connection refused
  • Moving from Ubuntu 14.04 32 bit to Ubuntu 14.04 64 bit
  • 2 Solutions collect form web for “How do I setup a docker image to dynamically pull app code from a repository?”

    If done right, the code “baked” into Docker images should be immutable and the only thing that should change at runtime is configurable parameters like environment variables (e.g. to set the port the app will listen on).

    Ideally, you should bake your code into the image. Otherwise you’re losing a lot of the benefit of using Docker in the first place.

    The problem is..

    .. your use case does not match with the best practice. You want an image without any code embedded in it, but rather fetched at each update. If you browse the docker hub you’ll find many image named as service:version. That’s one of the benefit of Docker, offering different versions of the same service. If you want to always get the most up-to-date code your workflow may have some down sides.

    One solution could be

    Webhooks, especially if your code is versionned on GH. Or any tools of continuous integration.

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