I have a Dockerfile
which I want to be built and pushed after jenkins maven build. I have these lines in my Dockerfile
:
...
ARG MAIN_DIR
ADD $MAIN_DIR .
...
And I pass MAIN_DIR
argument as follows:
docker build -t my.gitlab.com:4567/path/to/my/project/my-image-name:my-image-tag --build-arg MAIN_DIR=Development .
But I get:
ADD failed: stat /var/lib/docker/tmp/docker-builder832988213/Development: no such file or directory
EDIT 1:
COPY $MAIN_DIR .
generates the same issue.
EDIT 2:
Current directory actually contains a directory named Development
and I'm completely sure there is no .dockerignore
file in the whole project.
From our chat discussion the Dockerfile you are using is under the Development directory and you are using below to build the image
your
pwd
isSo when you send the context directory as the one containing the Dockerfile, then only content of that directory is sent to the docker daemon as context. And the development folder is in the parent hierarchy. So you won't be able to access anything that is above or outside the context folder.
Solution is to use a context directory which is separate from the Dockerfile