Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy files inside of docker image during build

I want to build a docker image that is based on dockerage/apache-mellon which has a volume on /var/www. I want to build my web app inside the docker container when I'm building it inside a temporary directory and than copy the files to /var/www with the following commands in my Dockerfile:

WORKDIR /tmp
COPY . /tmp
RUN ./node_modules/gulp/bin/gulp.js
RUN cp -R /tmp/dist/ /var/www

The docker build process finishes without any errors, but the files do not get copied to /var/www. Is there a way to copy files to a location which is declared as docker volume during build?

like image 561
Oskar Jauch Avatar asked Jun 24 '16 09:06

Oskar Jauch


1 Answers

You can't do it during the build. The volume is something that interacts with containers, not images. You could create an entrypoint script that copies the files to the volume when the container is launched, but i'm not sure that this would be a good solution

like image 76
Derek Avatar answered Sep 30 '22 10:09

Derek