Reputation: 429
I have the following file arrangement for a docker image (salmon
):
salmon
├── docker
│ └── Dockerfile
└── src
├── align_utils.py
├── job_utils.py
├── run_salmon.py
└── s3_utils.py
My entrypoint script in this case is run_salmon.py
, which also makes use of the other .py scripts in src/
. When I try to build the docker image via docker build -t salmon:pipeline .
within docker/
, I get the error:
COPY failed: stat /var/lib/docker/tmp/docker-builder013511307/src/run_salmon.py: no such file or directory
How do I figure out where the entrypoint script is located relative to the working dir in the dockerfile?
Dockerfile:
# Use Python base image from DockerHub
FROM python:2.7
# INSTALL CMAKE
RUN apt-get update && apt-get install -y sudo \
&& sudo apt-get update \
&& sudo apt-get install -y \
cmake \
wget
#INSTALL BOOST
RUN wget https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz \
&& mv boost_1_66_0.tar.gz /usr/local/bin/ \
&& cd /usr/local/bin/ \
&& tar -xzf boost_1_66_0.tar.gz \
&& cd ./boost_1_66_0/ \
&& ./bootstrap.sh \
&& ./b2 install
#INSTALL SALMON
RUN wget https://github.com/COMBINE-lab/salmon/releases/download/v0.14.1/salmon-0.14.1_linux_x86_64.tar.gz \
&& mv salmon-0.14.1_linux_x86_64.tar.gz /usr/local/bin/ \
&& cd /usr/local/bin/ \
&& tar -xzf salmon-0.14.1_linux_x86_64.tar.gz \
&& cd salmon-latest_linux_x86_64/
ENV PATH=$PATH:/usr/local/bin/salmon-latest_linux_x86_64/bin/
# Copy files to root directory of a Docker
WORKDIR /
COPY src/run_salmon.py /
COPY src/s3_utils.py /
COPY src/job_utils.py /
COPY src/align_utils.py /
ENTRYPOINT ["python", "/run_salmon.py"]
Upvotes: 2
Views: 1137
Reputation: 11346
When you run docker build -t salmon:pipeline .
from inside the docker
directory, you are specifying the current directory as a context for the build.
When the build run COPY src/run_salmon.py /
it tries to find the path relative to the root of your context (i.e., salmon/docker/src/run_salmon.py
), where the files don't exist.
It's better that you specify your root context as the salmon
directory, specifying the full path of the Dockerfile with the -f
flag. Run this from inside salmon
directory:
docker build -t salmon:pipeline -f docker/Dockerfile .
Upvotes: 2