dockerfile - How to change VOLUME to COPY in Docker? -


my workflow consists of 3 stages:

  1. development
  2. staging
  3. production

the docker configuration on 3 platforms same, except 1 difference. on development mount project directory via volume instead of copying via copy.

now wonder what's better practice?

create dockerfile each stage so

project/     .docker         development             apache-php                 dockerfile                 vhosts.conf             mariadb                 dockerfile         staging             apache-php                 dockerfile                 vhosts.conf             mariadb                 dockerfile         etc. 

or somehow conditionaly change volume copy, have no idea how should work.

use inheritance

create base image not cover copy/volume step , make dev-, test- , production dockerfiles base on base image.

example

base dockerfile

from ubuntu:14.04 run echo test >> /important.txt 

then build base image may referenced other dockerfiles: docker build -t baseimage .

dev dockerfile

from myrepo:baseimage volume somevolume 

build , run.

prod dockerfile

from myrepo:baseimage copy src dest  

build , run.

interesting

volumes override conatiner files if used that:

docke run -it -v ~/some.txt:/some/container/folder 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -