I am very new to Docker and I am able to successfully create an Image from Docker file but when I pulled it and ran a docker start on that it threw following error:
Error response from daemon: oci runtime error:
container_linux.go:247: starting container process caused "exec: \"./Myfolder\": stat ./Myfolder: no such file or directory".
The only place that I mentioned /Myfolder is in docker File ENTRYPOINT
as below ENTRYPOINT ["./Myfolder"]
While my Dockerfile looks like following:
FROM microsoft/dotnet:1.1.1-runtime
WORKDIR /opt/outputDirectory
ENTRYPOINT ["./Myfolder"]
COPY output /opt/outputDirectory
and this is assuming my entry point is the ENTRYPOINT project's directory name (the one containing /bin) what could I be missing?
ENTRYPOINT specify the program that runs inside the container. You've put a directory.
See this example:
FROM microsoft/dotnet:1.0-runtime
WORKDIR /app
COPY out ./
ENTRYPOINT ["dotnet", "dotnetapp.dll"]
Related
I'm new to docker, sorry if my question is too basic, below is my dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
COPY dist /app
WORKDIR /app
EXPOSE 80/tcp
ENTRYPOINT ["dotnet", "ExampleApp.dll"]
I got an error:
"exampleApp encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified."
So I created an image and start an instance, it was running OK.
But when I try to copy a file to the container:
docker cp ./Views/Home/Index.cshtml exampleApp:/app/Views/Home/
there is a "no such directory" error in powershell, then I ran docker diff exampleApp to see the file system, I couldn't find the app directory in the container:
bur I did specify app as working directory inside the container, so why this folder is not appearing in the container?
For a Docker images for ASP.NET Core, I would add to your Dockerfile right after the COPY line:
RUN dir . /s /b sortorder:N
Just to make sure what has been copied, and if the /app/Views/Home/ does indeed exist.
I build a Go docker image from docker file successfully, but docker run -p port:port --name imagename imageid gives me permission denied error.
This is my docker file
FROM golang:1.17.2-alpine3.13 as build
WORKDIR /app
COPY . .
RUN go build -o app
FROM alpine:3.7
COPY --from=build /app /usr/local/bin/go_webhooks
RUN chmod +x /usr/local/bin/go_webhooks
ENTRYPOINT ["/usr/local/bin/go_webhooks"]
I tried using chmod but still could not solve it.
The actual error message is:
docker run -p 8000:8000 --name go_webs3 d5f30e8f9703
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:380: starting container process caused: exec:
"/usr/local/bin/go_webhooks": permission denied: unknown.
ERRO[0000] error waiting for container: context canceled
A past similar error message pointed out to a go build issue.
But in your case, copying a folder to /usr/local/bin/go_webhooks would make go_webhooks a folder.
WORKDIR /app
# means /app is a folder
You cannot directly execute a folder.
Your Entrypoint needs to reference an executable inside that folder.
You might needs to copy the built file inside /app:
COPY --from=build /app/app /usr/local/bin/go_webhooks
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"]
This is quite strange.
I have a structure like this
app/
CLI/
someOtherFolder/
thingIwantToRun.py
tests.Dockerfile
Dockerfile
README.md
gunicorn.conf
This is what my Dockerfile looks like
FROM python:3.6
WORKDIR /app
COPY ./requirements.txt /.requirements.txt
# Install any needed packages specified in requirements.txt
RUN pip install -r /.requirements.txt
COPY gunicorn.conf /gunicorn.conf
COPY . /app
EXPOSE 8000
RUN ls
ENV FLASK_ENV=development
CMD ["python ./someOtherFolder/thingIwantToRun.py"]
This gives me this error when I start the container -
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"ls ./someOtherFolder\": stat ls ./someOtherFolder: no such file or directory": unknown.
When I change the CMD command into something else which doesn't fail and I jump into the container I see that my folder is indeed there.
When I add a RUN ls into my Dockerfile, I can still see my folder.
If it exists, why can't I run it?
UPDATE -
If I move thingIWantToRun.py into the top level folder and change my Docker CMD to
CMD [python thingIWantToRun.py]
I see the same issue. However, I can ssh into the container and verify that the file is there.
The problem is how you are running the CMD command. It is something like this:
CMD ["executable", "param1", "param2"]
ref: https://docs.docker.com/engine/reference/builder/#cmd
In that sense actual command should be
CMD ["python", "./someOtherFolder/thingIwantToRun.py"]
Docker tries to find the executable part (first item of the array) and run it, and passes rest of the array items (param1, param2) to it. If you look closer to the error is prints
... process caused "exec: \"ls ./someOtherFolder\": stat ls ./someOtherFolder: no such file or directory"
It says that ls ./someOtherFolder is not a file or directory and it can't exec it! Which is the first item of the array, the executable!
Here ls should be first item and ./someOtherFolder should be second item of array for CMD command.
You need to use the CMD command something like this:
CMD ["python", "./someOtherFolder/thingIwantToRun.py"]
My Dockerfile looks like below:
FROM scratch
RUN skype
I have skype installed in my OS and when I try to build the docker with below command:
sudo docker build -t tryskyped .
It says
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM scratch
--->
Step 2/2 : RUN skype
---> Running in 0ecf7c719567
container_linux.go:247: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory"
oci runtime error: container_linux.go:247: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory"
If I am not wrong it should have executed like /bin/sh -c skype. When I manually try this , I can see the skype opens
I am very new to this and I am just trying out docker.Please help
Your Dockerfile does nothing, as it does not have a CMD or ENTRYPOINT to execute.
A Dockerfile has a configuration phase (the RUN, ADD, COPY and so) and a start phase, with ENTRYPOINT and CMD
As an example, the last line of the Dockerfile for the Nginx image reference contains
extract from
https://github.com/nginxinc/docker-nginx/blob/0c7611139f2ce7c5a6b1febbfd5b436c8c7d2d53/mainline/jessie/Dockerfile
CMD ["nginx", "-g", "daemon off;"]
Check What is the difference between CMD and ENTRYPOINT in a Dockerfile?
The doc for CMD
https://docs.docker.com/engine/reference/builder/#cmd
for ENTRYPOINT
https://docs.docker.com/engine/reference/builder/#entrypoint