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.

  • Create Docker container with Nodev4.4.7 and Python3
  • Docker Hello World fails
  • MySQL docker container crashes
  • Creating docker image that executes commands in python virtualenv
  • Add file to jenkins workspace with docker
  • Using rbenv with Docker
  • How to forward an additional port to docker container created by mupx?
  • Docker swarm with Glassfish 3.1.2.2 image fails to start nodes
  • Docker - logging to Graylog2 container with GELF log-driver raises an error
  • Using the Erlang Observer App with a remote Elixir Phoenix server inside Docker
  • How to check the status of an image using docker-java library
  • docker elevate user priviledges
  • 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.