I have a dockerfile
FROM myregistry.de/public/12/s11
LABEL maintainer="Me"
COPY ./somefile.txt /opt
CMD /bin/sh
the file I want to copy to Docker Container is in the same folder as the Dockerfile
But when I do docker build -t 'name:tag4' .
I get the error message :
COPY failed: file not found in build context or excluded by .dockerignore: stat somefile.txt: **file does not exist**
So why is this simple copy not working ?
Please check what you get in build context directory by creating another Dockerfile with the following content:
FROM myregistry.de/public/12/s11
RUN mkdir /tmp/build
COPY . /tmp/build
CMD /bin/sh
Then build and run the container and check /tmp/build folder contents.
Related
I'm getting following error when I run Dockerfile with AWS CodePipeline
Step 2/4 : COPY src /app
COPY failed: file not found in build context or excluded by .dockerignore: stat src: file does not exist
This is the command used in buildspec.yml
docker build --tag $REPOSITORY_URI:$TAG -f app/Dockerfile .
folder structure is:
Microservice1/
|-app/
|- src/
|- Dockerfile
|-buildspec.yml
You are executing command at $Microservice1 directory.
Dot (.) at the end of command tells to use build context as current directory.
Docker build context can see only app/src , only src is not visible.
Alternatively, execute command from $Microservice1/app directory. You may have to change Dockerfile a bit.
I am trying to copy my project into app folder.
Dockerfile
FROM ubuntu:18.04
RUN mkdir /app
ARG input_project_path
COPY $input_project_path /app
When I run the docker build command it returns the following error and I am running the docker build command in the same directory as my Dockerfile.
ubuntu:~/$ sudo docker build --build-arg input_project_path=/home/ubuntu/web-app/ -t test .
COPY $input_project_path /app
COPY failed: stat /var/lib/docker/tmp/docker-builder055576899/home/ubuntu/web-app/: no such file or directory
You should put all the files/directories that you want to use in COPY in the same directory where your Dockerfile is present.
Try this:
COPY ${input_project_path} /app
I'm trying to build an image of a .netcore v2.2 WebAPI app from docker file. But I'm getting a "no such file or directory" error while I try to build the image using following command:
docker build -t helloworld .
I have both microsoft/dotnet "latest" and "2.2-aspnetcore-runtime" base images installed in my machine.
Here's my docker file
FROM microsoft/dotnet
RUN mkdir /app
COPY ./bin/Release/netcoreapp2.2 /app
WORKDIR /app
ENTRYPOINT ["dotnet", "/app/HelloWorld.dll"]
# ASP.NET Core: Kestrel should listen on all IPs
ENV ASPNETCORE_URLS="http://0.0.0.0:5000"
Here's the folder structure of my solution (I tried the command inside the src):
Here's the output directory
Here's the full error details from the docker:
COPY failed: stat /var/lib/docker/tmp/docker-builder896068669/bin/Release/netcoreapp2.2: no such file or directory
you may change ./bin/Release/netcoreapp2.2 to ./bin/release/netcoreapp2.2
folder names are case sensitive
It seems the file ./bin/Release/netcoreapp2.2/publish does not exists on the machine on which you are running docker build
When you run docker build -t helloworld . it will copy all the file in . (i.e. the current directory from which you run the command) to the build context which will then be used when running COPY instructions, so you need to make sure you are running your command from the proper directory where files will be available to COPY
You can also run the same command from another directory by specifying the path to be used as build context such as docker build -t helloworld /path/to/my/dir
I want to build a docker image of a composer from this page composer:latest and taking exactly this Dockerfile
but when I do this in console:
$ wget -O Dockerfile https://raw.githubusercontent.com/composer/docker/edf4f0abf50da5d967408849434b9053a195b65f/1.7/Dockerfile
$ docker build -t mycomposer:latest .
i got this build error:
Step 9/12 : COPY docker-entrypoint.sh /docker-entrypoint.sh COPY
failed: stat
/var/lib/docker/tmp/docker-builder787686173/docker-entrypoint.sh: no
such file or directory
How come I have any error building from official Dockerfile?
This way works:
$ docker pull composer:latest
but I need to build an image basing on a local Dockerfile instead of just pulling it.
The command
COPY docker-entrypoint.sh /docker-entrypoint.sh
in the Dockerfile tries to copy the file docker-entrypoint.sh from your current directory.
However you have only downloaded the Dockerfile.
If you visit the actual directory on the repository you will notice another file entitled
docker-entrypoint.sh. If you download this file too and place it in the same directory
as the Dockerfile the image will be built without errors.
I have auto generated the following docker file with sbt for my scala project:
FROM robsonoduarte/8-jre-alpine-bash:latest
WORKDIR /opt/docker
ADD opt /opt
RUN ["chown", "-R", "daemon:daemon", "."]
EXPOSE 6999
USER daemon
ENTRYPOINT ["bin/app"]
CMD []
Yet when I run build . -t app I get the following error:
Sending build context to Docker daemon 166.2MB
Step 1/7 : FROM robsonoduarte/8-jre-alpine-bash:latest
---> 9bbc00a23a9b
Step 2/7 : WORKDIR /opt/docker
Removing intermediate container 817f86d4a46e
---> b648d213f308
Step 3/7 : ADD opt /opt
ADD failed: stat /var/lib/docker/tmp/docker-builder679116314/opt: no such file or directory
I have tried to reinstall docker as suggested in another SO answer, but that did not help. I am also using windows, and I cannot find the /var/lib folder.
The ADD command copies files from <src> to <dest>. In your case, Docker expects a folder called 'opt' from the location where you run build . -t app. Does such a folder exist?