Docker compose specifying image vs Dockerfile -


i'm new docker-compose , after reading docs still have unclear things comes mind.

so far when used docker kept builds in following directory tree:

builds:     service a:         dockerfile         servicea.jar     service b:         dockerfile         serviceb.jar 

so when want run use shell script, until read docker-compose.

i saw there 2 ways of creating , running service (in manner of copying files)

  1. specifying build: path/to/my/build/directory , linking volumes: can see live code , refresh service
  2. specifying image: (for example java:8) , use volumes: above

what want understand best practice using docker-compose before dive in it, should create specify image each service (and replace from inside dockerfile) or should specify paths build folders , volumes keep live code changes, , how volumes work , usages when using image tag

thanks!

in docker can run services containers , can put state of each service in volume. means you:

  • the service run runtime container started image.
  • the service's binaries inside image, service writes data volumes.
  • the image can either pulled image repository or build on target environment.
  • images can build command docker build or docker-compose build section.

in example means:

  1. keep directory structure.
  2. use docker-compose build section build immages according dockerfiles.
  3. configure dockerfile put binaries inside image.
  4. simply start whole stack including build docker-compose -d
  5. your binaries changed? replace whole stack docker-compose --build --force-recreate -d. command rebuild images , replace containers.

why not place binaries inside volume:

  • you lose advantage of image versioning.
  • if replace binaries files cannot fallback older image version.
  • you can retag images before deploy new version , fallback if error occurs.
  • you can tag , save running containers fallback , error investigation.

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -