Recommended Project Structure for Docker

I’m working on a Go project that has the following structure (schematic):



  • How to mount a folder in a container as locally
  • Docker and node_modules - put them in a layer, or a volume?
  • How to run multiple boot2docker with docker-machine?
  • Running bvlc-caffe docker image as non-root user results in unexpected NVCC flags
  • boot2docker behind proxy - certificate signed by unknown authority
  • OSX / Mac with Kitematic / Docker : Tunnel / Port forwarding for access via external url
    • lib1 is a library
    • prog1 and prog2 are executables (both depend on lib1)

    In a nutshell: How do I create Dockerfiles for prog1 and prog2?

    I tried several approaches, all to no avail:

    Creating a Dockerfile in prog1/

    Failed because docker cannot ADD ../lib1 to the container since it is out of the context (see

    Creating a Dockerfile in the root directory

    Ignoring the fact that I actually need two Dockerfiles (for prog1, and for prog2), I tried placing the Dockerfile in the root directory of the project.

    However, the docker image I need to use (golang:1.4.1-onbuild) fails to find any Go files (since they are in ./prog1, and not in the root):

    + exec go install -v
    can't load package: package app: no buildable Go source files in /go/src/app

    What is the recommended project structure for the golang:1.4.1-onbuild image?

    Edit: Better asked here:

  • Prometheus - Docker/JVM Monitoring
  • Mesosphere inter-service communication using Marathon
  • Migrating from shared development database to single database for each developer
  • How to run Linux libraries on Docker on Windows?
  • can't upate php.ini file in Docker container
  • Redis Exited While Run With Persistent Data In Boot2Docker
  • One Solution collect form web for “Recommended Project Structure for Docker”

    Most pull the files in via their VCS or just go get instead of using ADD. You add the the source tree in the same way regardless of what tool your building, since you need the structure of $GOPATH to be the same for each.

    Note, you can also name your docker file via docker build -f, so if you want to use ADD, you can have multiple DOCKERFILEs in your root directory.

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