docker - Dockerfile: Copied file not found -
i'm trying add shell script container, , run part of build.
here's relevant section of dockerfile:
#phantomjs install copy conf/phantomjs.sh ~/phantomjs.sh run chmod +x ~/phantomjs.sh && ~/phantomjs.sh
and here's output during build:
step 16 : copy conf/phantomjs.sh ~/phantomjs.sh ---> using cache ---> 8199d97eb936 step 17 : run chmod +x ~/phantomjs.sh && ~/phantomjs.sh ---> running in 3c7ecb307bd3 [91mchmod: [0m[91mcannot access '/root/phantomjs.sh'[0m[91m: no such file or directory[0m[91m
the file i'm copying exists in conf folder underneath build directory... whatever doesn't seem copied across.
tl;dr
don't rely on shell expansions ~
in copy
instructions. use copy conf/phantomjs.sh /path/to/user/home/phantomjs.sh
instead!
detailed explanation
using ~
shortcut user's home directory feature offered shell (i.e. bash or zsh). copy
instructions in dockerfile not run in shell; take file paths argument (also see manual).
this issue can reproduced minimal dockerfile:
from alpine copy test ~/test
then build , run:
$ echo foo > test $ docker built -t test $ docker run --rm -it test /bin/sh
when running ls -l /
inside container, you'll see docker build
did not expand ~
/root/
, created directory named ~
file test
in it:
/ # ls -l /~/test.txt -rw-r--r-- 1 root root 7 jan 16 12:26 /~/test.txt
Comments
Post a Comment