NRKirby
NRKirby

Reputation: 1634

Unable to copy files from cloned repo in Dockerfile

In my Dockerfile I want to clone some source code and copy all the files/directories from the cloned repo to the file system of the container but I am getting the following error:

COPY failed: stat /var/lib/docker/tmp/docker-builder686077620/my-repo: no such file or directory

My Dockerfile looks like this

FROM ubuntu

ARG GIT_USER
ARG GIT_TOKEN
RUN apt-get update
RUN apt-get install -y git
RUN git clone -n https://${GIT_USER}:${GIT_TOKEN}@github.com/<username>/my-repo
COPY my-repo/ /app

My build command is: docker build -t git-test --build-arg GIT_USER=<user>-- build-arg GIT_TOKEN=<token>

Can anyone see what I'm doing wrong here?

Upvotes: 0

Views: 2382

Answers (2)

user12640668
user12640668

Reputation:

Or you might create the directory where you clone

  1. RUN mkdir -p /your/path/ && cd /your/path \ && git clone <URL>

Upvotes: 1

Frank Hopkins
Frank Hopkins

Reputation: 695

Wouldn't the RUN command run 'inside' the docker container, while COPY tries to copy something from outside to the inside? i.e. if you clone it inside you don't need to COPY it. Either directly clone it to where you need it or use something like RUN mv ... or RUN cp my-repo /app/

Upvotes: 4

Related Questions