First, I build a Quarkus native image, everything seems to be fine. When I try to run it, I get the following error:
standard_init_linux.go:228: exec user process caused: no such file or directory
This is the Dockerfile:
FROM alpine:3.15
WORKDIR /deployment/
COPY native/*-runner /deployment/app
RUN chmod 775 /deployment
EXPOSE 8082
USER 1001
ENTRYPOINT [ "./app","-Dquarkus.http.host=0.0.0.0"]
I'm on a Windows machine and the command used to generate the native executable (the *-runner file) is:
mvn package -Pnative -Dquarkus.package.type=native -Dquarkus.native.container-build=true
I'm not sure what I'm doing wrong, after browsing similar issues, some were solved with the -Dquarkus.native.container-build=true flag, but it didn't work in my case. Thank you !
The problem was in the Dockerfile, I was using alpine:3.15 as base image.
After reading the guide again, this fixed the problem:
FROM quay.io/quarkus/quarkus-micro-image:1.0
Related
I was trying to get a minimal example go app running inside a docker container.
But I kept getting exec /app: no such file or directory when running the container.
I checked and double checked all my paths in the image where I built and copied my application data, even looked inside the container with interactive shell to verify my app was there but nothing worked.
My Dockerfile:
# syntax=docker/dockerfile:1
# BUILD-STAGE
FROM golang:1.17-alpine as build
WORKDIR /go/app
COPY . .
RUN go mod download
RUN go build -o /go/bin/app
# RUN-STAGE
FROM gcr.io/distroless/static-debian11
COPY --from=build /go/bin/app .
EXPOSE 8080
CMD ["./app"]
After several hours of try and error I finally tried to add CGO_ENABLED=0 to my go build command.... and it worked!
My question is now.... why exactly does this happen?
There was no error when I built my image with CGO implicitly enabled and I even verified that the binary was copied into my second stage!
Why does the runtime say there is no such file when it was built using CGO, but can find it easily when it was built with CGO disabled?
The image that you are using does not contain libc 1 which you build your go app against when using CGO_ENABLED=1.
As suggested in 1 you can use gcr.io/distroless/base.
There was no error when building your app because golang:1.17-alpine contains musl libc (something like libc but smaller).
Then you tried running the app that required libc in an environment that does not have it anymore. So the no such file error.
google container tools
I have an application I'm creating a docker image for, the image is created but when I run it the container errors saying it cannot find the executable file.
Here is my docker file:
FROM alpine:3.14
WORKDIR /
EXPOSE 3000
COPY ./weather-api /weather-api
CMD ["/weather-api"]
I've included a RUN ls -la immediately above the CMD which shows the file is there whilst building the image is being built, and I've included a shell script with la -la as the CMD which has shows that the files is there when the image is being ran.
This is the error I'm getting:
standard_init_linux.go:228: exec user process caused: no such file or directory
When I try to call the weather-api from a shell script I get the standard file not found error.
I've tried using an absolute and relative path for the command, copying the file to /usr/local/bin which I think should put it on the PATH so it would be callable from anywhere, changing COPY to ADD.
I'm still new to docker so any help would be greatly appreciated.
I'm new to docker and am trying to dockerize an app I have. Here is the dockerfile I am using:
FROM golang:1.10
WORKDIR /go/src/github.com/myuser/pkg
ADD . .
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
RUN dep ensure
CMD ["go", "run", "cmd/pkg/main.go"]
The issue I am running into is that I will update source files on my local machine with some log statements, rebuild the image, and try running it in a container. However, the CMD (go run cmd/pkg/main.go) will not reflect the changes I made.
I looked into the container filesystem and I see that the source files are updated and match what I have locally. But when I run go run cmd/pkg/main.go within the container, I don't see the log statements I added.
I've tried using the --no-cache option when building the image, but that doesn't seem to help. Is this a problem with the golang image, or my dockerfile setup?
UPDATE: I have found the issue. The issue is related to using dep for vendoring. The vendor folder had outdated files for my package because dep ensure was pulling them from github instead of locally. I will be moving to go 1.1 which support to go modules to fix this.
I see several things:
According to your Dockerfile
Maybe you need a dep init before dep ensure
Probably you need to check if main.go path is correct.
According to docker philosophy
In my humble opinion, you should create an image with docker build -t <your_image_name> ., executing that where your Dockerfile is, but without CMD line.
I would execute your go run <your main.go> in your docker run -d <your_image_name> go run <cmd/pkg/main.go> or whatever is your command.
If something is wrong, you can check exited containers with docker ps -a and furthermore check logs with docker logs <your_CONTAINER_name/id>
Other way to check logs is access to the container using bash and execute go run manually:
docker run -ti <your_image_name> bash
# go run blablabla
When I try to build this Docker-Image, I get the following error:
FROM java:8
WORKDIR /app
ADD . /app
EXPOSE 8080
RUN ./gradlew build
CMD ./gradlew bootRun
When I just build the app with "gradlew build" it runs and when I try to run this Docker Image with a Mac, it works too, just not for windows
EDIT:
This is not a great answer, but what I found is that when Windows mounts files into Docker from Windows, it leaves Windows-like line endings on the mounted files. A janky way to solve it in your Dockerfile would be to install dos2unix in the container and add a
RUN dos2unix gradlew
prior to executing your build process. Unfortunately, this is a TERRIBLE solution. Hopefully Docker for Windows on WSL2 that is supposed to release soon will solve this better but for now you are stuck with this janky solution.
gradlew must be marked as executable.
chmod +x gradlew
Mac and Linux share permissions scheme but Windows needs to use a virtual FS so it copies files with default permissions - 644 and you need 755.
Im new to docker and trying to learn it.
Im following this tutorial: https://docs.docker.com/get-started/part2/#apppy
So I installed Docker on Windows.
Created 3 files, app.py, Dockefile and requirements.txt
My docker file looks like this
# Use an official Python runtime as a parent image
FROM python:2.7-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt
# Make port 80 available to the world outside this container
EXPOSE 80
# Define environment variable
ENV NAME World
CMD ["python", "app.py"]
When I run it in powershell
docker build -t friendlybuild .
But as result it gives this:
Error response from daemon: Dockerfile parse error line 1: unknown instruction: #
Like it doesnt work
I have no idea why it doesnt work
I forgot to have a whitespace in ENTRYPOINT["java",
It should be ENTRYPOINT ["java",
I just tested the same and by default VSCode seems to save the Dockerfile with UTF-16 LE encoding.
Resaving the file as UTF-8 allowed docker build to run without error.
Solved by removing the dockerfile and creating it with Notepad instead of Visual Code
I had an extra line break in my Dockerfile. Didn't even notice it until I read some of these comments and realized it could be a problem. Originally my file was:
FROM openjdk:8
COPY . /usr/src/Main
WORKDIR /usr/src/Main
ENTRYPOINT ["java", "-Xmx700m","-classpath", ".:./resources/:./lib/*",
"org.spark.docker.demo.DockerMultilayerPerceptronClassifier"]
and the error I was seeing was:
$ docker build -t docker-classifier .
Sending build context to Docker daemon 248.3MB
Error response from daemon: Dockerfile parse error line 5: unknown instruction: "ORG.SPARK.DOCKER.DEMO.DOCKERMULTILAYERPERCEPTRONCLASSIFIER"]
Took me a while to figure it out until I read some of these comments above and looked into the line formatting and realized "org.spark.docker.demo.DockerMultilayerPerceptronClassifier"] was on a line of it's own. Once I removed the line break before it everything worked fine. I assumed the parser would ignore it.
When doing it from Windows, I had to make sure that I have line breaks in my Dockerfile configured for Linux (LF) and not for Windows (CRLF) when editing it from a text editor.
In Google Cloud Platform in console project using nano the comand work for me
1ยบ-nano
2-
# The Dockerfile defines the image's environment
# Import Python runtime and set up working directory
FROM python:2.7-alpine
WORKDIR /app
ADD . /app
# Install any necessary dependencies
RUN pip install -r requirements.txt
# Open port 80 for serving the webpage
EXPOSE 80
# Run app.py when the container launches
CMD ["python", "app.py"]
save the file...
I experienced this issue when working on a React app setup on Docker.
Sending build context to Docker daemon 1.143MB
Error response from daemon: Dockerfile parse error line 1: unknown instruction: +#
Here's how I solved it
The issue was that I had another file named Dockerfile (capital case D) which had some instructions in it, and it was conflicting with the original dockerfile (lower case d) in my project root directory.
I fixed this by deleting the Dockerfile and running the command:
docker build t myapp:latest .
to build the docker image from the dockerfile instead.
That's all.
I hope this helps
While running, appended some text in the start of the file. Removed those using vi in terminal and working fine.
i run docker compose in intellij idea, solved this by remove the number in docker parent folder name.
For mac users who face this issue:
Just edit/create Dockerfile using Python IDLE and remove extension.