File not found exception while running DockerFile - docker

Here my DockerFile :-
FROM openjdk:10
ENV AQUILA_HOME /data/config
#USER root
#VOLUME /tmp
ADD a2i-web-1.0.0-SNAPSHOT.jar app.jar
#RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java","-jar","app.jar"]
My jar is spring boot application which refers configuration file from some directory [/data/config/config.properties]
I am building DockerFile successfully by command
sudo docker build -t dockImgName/a2i-web:v1 .
But while running it by command
sudo docker run -p 8080:8080 -t dockImgName/a2i-web:v1
giving exception as :
Caused by: java.io.FileNotFoundException: /data/config/config.properties (No such file or directory)
I am running this dcoker command from directory containing DockerFile and my jar
Do I need to set any configuration to get config file directory?

The error message is quite clear. When the container tries to run it is not able to find properties file.
You need to add config.properties file to your docker image.
ADD path_to_config_file/config.properties /data/config/config.properties
NOTE: path_to_config_file refers to the file path in your local where you are building the dockerfile

Related

Where am I going wrong with my Dockerfile?

I've created a Dockerfile at the root of a directory that contains a web application. My Dockerfile reads as follows:
FROM openjdk:8u282-jre
MAINTAINER me <me#email.com>
COPY target/spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar /
EXPOSE 8080
ENTRYPOINT ["java -jar"]
I'm attempting to copy a jar file from my local machine using the path from the within the root of the project directory - copying this to the root of the container, expose port 8080, and use an entry point thinking that after building the image, the jar will be run as an executable using this entry point. I then built the image as follows:
docker build -t se441/spring-petclinic:standalone .
Giving the build the name se441/spring-petclinic:standalone, I then attempt to run the container:
docker run -i -t se441/spring-petclinic:standalone
And I am getting the following error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:370:
starting container process caused: exec: "java -jar": executable file not found in $PATH:
unknown.
I edited the Dockerfile to have the entry point be a /bin/bash, did an 'ls' and the jar file is definitely there. While in the container, I can run the jar successfully. Any advice on why the jar file can't be found when building/running with the Dockerfile as I've listed above. would be greatly appreciated. Thank you.
Change:
ENTRYPOINT ["java -jar"]
to:
ENTRYPOINT ["java", "-jar"]
The exec syntax (with the json array) does no do any command line parsing that you get with a shell, so it's looking for the literal binary java -jar rather than java and passing the -jar argument. You need to separate each parameter as another array entry, just as you'd separate them with spaces on the command line.
At that point, you'll find that -jar expects the name of the jar file. You can pass that as an argument when you run the container, e.g.:
docker run -i -t se441/spring-petclinic:standalone spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar
Or specify that as well in the entrypoint:
ENTRYPOINT ["java", "-jar", "spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar"]

airflow exporter - binary build dockerfile error

When I build binary and package to alpine image for airflow exporter with my Dockerfile I am getting error.
Not sure how to fix this error.
+++++ Error while docker build +++++++++
---> Running in caebfe9a04a0
stat mage.go: no such file or directory
The command '/bin/sh -c cd /go/src/github.com/airflow_exporter/; go run mage.go binary' returned a non-zero code: 1
+++++++++++++++
++++++++++++++++ My Dockerfile +++++++++++++++++
FROM golang:1.11.1 AS builder
RUN mkdir -p /go/src/github.com/airflow_exporter
ADD . /go/src/github.com/airflow_exporter
RUN cd /go/src/github.com/airflow_exporter/;
go run mage.go binary
FROM alpine:3.4
COPY --from=builder /go/src/github.com/airflow_exporter/bin/*/airflow_exporter /airflow_exporter
EXPOSE 9112
ENTRYPOINT [ "/airflow_exporter" ]
+++++++++++++++++++++++++++++++++
The first line in your docker build output shows that the binary file mage.go is not in the expected location (stat mage.go: no such file or directory). Check through the steps that lead up to reading that binary. I would look through the following:
Check that the directory from which your docker file is being run
actually contains the mage.go binary, since you are adding the
contents of your pwd to the airflow_exporter (ADD .
/go/src/github.com/airflow_exporter)
Try adding the full file path to mage.go
If the above fails, try running your own stat commands on the file throughout the process, and continue breaking down the problem from there

Ubuntu Docker - php composer build from the official Dockerfile fails, COPY failed Step 9/12 stat no such file or directory

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.

OCI runtime create failed: container_linux.go:296 - no such file or directory

End of my Dockerfile:
ENTRYPOINT ["ls /etc"]
Terminal:
...Rest of the building above is fine
Step 8/8 : ENTRYPOINT ["ls /etc"]
---> Using cache
---> ea1f33b8ab22
Successfully built ea1f33b8ab22
Successfully tagged redis:latest
k#Karls ~/dev/docker_redis (master) $ docker run -d -p 6379:6379 --name red redis
71d75058b94f088ef872b08a115bc12cece288b53fe26d67960fe139953ed5c4
docker: Error response from daemon: OCI runtime create failed: container_linux.go:296: starting container process caused "exec: \"ls /etc\": stat ls /etc: no such file or directory": unknown.
For some reason, it won't find the directory /etc. I did a pwd and the current working directory is /. I also did a ls / on the entrypoint and that displayed the /etc directory fine.
OCI runtime create failed: container_linux.go:296
In my experience this is an error with the docker daemon itself, not the container you are trying to run. Try deleting all containers, restarting the daemon. I think we also had to clean up the docker networks.
I appear to be having the same issue. Here is what I am doing.
Dockerfile
FROM gcc:7.2.0
COPY src/ /usr/src/myapp
WORKDIR /usr/src/myapp
RUN set -x gcc -o myapp main.c
CMD ["./myapp"]
Build
$ docker build -t test .
Sending build context to Docker daemon 3.584kB
Step 1/6 : FROM gcc:7.2.0
...
---> 3ec35c7d2396
Successfully built 3ec35c7d2396
Successfully tagged test:latest
SECURITY WARNING: You are building a Docker image from Windows against a
non-Windows Docker host. All files and directories added to build context
will have '-rwxr-xr-x' permissions. It is recommended to double check and
reset permissions for sensitive files and directories.
Run
$ docker run -it test
D:\Docker Toolbox\docker.exe: Error response from daemon: OCI runtime create
failed: container_linux.go:296: starting container process caused "exec:
\"./myapp\": stat ./myapp: no such file or directory": unknown.
Changed CMD to ENTRYPOINT and removed the set -x seemed to resolve the problem. Though we are still unsure what the cause was or if this will also work for you.
Make sure that /etc exists or is created as the main.c wasn't compiling.
Dockerfile
FROM gcc:7.2.0
COPY src/ /usr/src/myapp
WORKDIR /usr/src/myapp
RUN gcc -o myapp main.c
ENTRYPOINT ["./myapp"]
On OSX, I fixed it by clearing the volume data manually. Close docker, and remove everything in ~/Library/Containers/com.docker.docker
I've expirienced the same issue after updating my Windows credentials, try following: Docker settings > Shared Drives > Reset credentials > Select drives again > Apply and re-enter your credentials. This solved the problem for me multiple times
The command you are trying to execute inside the container does not exist. In this case ls /etc does not exist in the image. There's a /bin/ls binary, but not a /bin/"ls /etc" binary, which itself would be invalid since the name of a file on the filesystem cannot include a /, though it can include a space.
Of course what you wanted to run was ls with the argument /etc, and for that, you need to separate each argument if you run with the exec syntax.
ENTRYPOINT ["ls", "/etc"]
Or if you wanted to allow a shell to parse the string, same way as if you were at a bash prompt inside the container running ls /etc on the command line, then switch to the string syntax that runs a shell:
ENTRYPOINT ls /etc

Docker- Image and Container to build and run an Executable file

Am new to Docker technologies, I have build an executable file in Visual Studio 2015 on Windows 10 machine.
Am looking to dockerize this executable file. I have build an Image and Container but the exe file is not being execute.
Here is my work so far:
Docker file:
FROM microsoft/aspnetcore:1.1
COPY . /app
WORKDIR /app
ENTRYPOINT ["dotnet","Controller.exe"]
CMD ["Controller.exe","RUN"]
Command used to create Image:
docker build -t imagename:version
Command used to create controller:
docker run -it --name Controller_name Image_ID run
Am trying to start the controller, but the controller is not starting
I have performed docker logs and here is the information in the log file.
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\app'.

Resources