airflow exporter - binary build dockerfile error - docker

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

Related

How to Wrap an Executable in Docker?

I have an executable binary called abin that I want to containerize. All abin does is output a test string via printf. So I create a directory called test, which contains only abin and the following Dockerfile:
from alpine:3.7
copy abin /
entrypoint /abin
So I sudo docker build -t test/testy:tag . && sudo docker run --rm test/testy:tag, and get the following:
/bin/sh: /abin: not found
This baffles me for two reasons:
why is sh running despite setting the entrypoint to /abin?
why is /abin not found?
Changing the entrypoint to stat /abin then re-building and re-running gives the expected stat output, clearly indicating that there's an executable file at /abin. By the same token, removing the entrypoint and running in the container's interactive shell, I can see the abin file, and I can ls or stat and cat etc., but ./abin or /abin still give the /bin/sh: ./abin: not found error.
EDIT:
I incorrectly assumed that Alpine ran the same kind of binaries as most linuxes. Not so. Also, it doesn't even come with stdio - my second mistake. Lastly, I needed to specify the entrypoint as an absolute path. Thus the following Dockerfile works:
from alpine:3.7
workdir /
copy test.c .
run apk add gcc libc-dev && gcc test.c -o abin
entrypoint ["/abin"]
If your entrypoint is not inside square brackets, Docker will call sh <entrypoint>. Use ENTRYPOINT ["abin"] instead and I believe it should work.

binary file not found on doing go build -o /bin/go_docker inside a docker file

below is the content of the dockerfile
FROM golang:1.8 as goimage
ENV SRC=/go/src/
RUN mkdir -p /go/src/
RUN mkdir /go/src/go_docker
WORKDIR /go/src/go_docker
RUN cd /go/src/go_docker
COPY StoreImage.go .
RUN go build -o /bin/go_docker
CMD ["/bin/go_docker"]
Docker build is successful for the above content.. But dont see the binary file generated in /bin/go_docker
Can someone please help me with this.
Make sure StoreImage.go can copy into docker
Binary file is created in /bin location and go_docker is the created binary file.
.exe will not be the extension in linux whereas .exe will be seen only in windows

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.

docker run complains file not found

I am running following command for build docker image from /etc/docker and all files I want to copy inside the container are at this same location
docker build -t user/testapp .
Following is the content of my Dockerfile:-
FROM openjdk:alpine
COPY . /usr/src/testapp/
WORKDIR /usr/src/testapp/
CMD TestAppStart
Image builds fine but when running it uwing following command it says:-
/bin/sh: /usr/src/testmq/TestAppStart
I also tried absolute path in CMD but same error.
I have verified that the files are getting copied by changing CMD to /bin/sh the container starts and I get a shell inside it and I can navigate to that directory and see all the files and can even run the TestAppStart from there manually.
Need help!
The /usr/src/testapp/ directory is not in the PATH environment variable, so /bin/sh complains.
Change the last line to:
CMD ./TestAppStart

Why not found, while it does exist?

At windows 10, when I run:
$ docker build .
I get this error in console:
RUN /provision/provision.sh
---> Running in e66928c3c893
/bin/sh: 1: /provision/provision.sh: not found
My folder files:
/Dockerfile
/provision
/provision/provision.sh
So why I get /bin/sh: 1: /provision/provision.sh: not found error, although /provision/provision.sh exists ?
EDIT
I tried:
ADD provision /provision
And I tried:
COPY provision /provision
Didn't work..
Step 7 : COPY provision /provision
---> c5d07de6948d
Removing intermediate container 85768981a7f0
Step 8 : RUN /provision/provision.sh
---> Running in 8426a8526514
/bin/sh: 1: /provision/provision.sh: not found
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.
The command '/bin/sh -c /provision/provision.sh' returned a non-zero code: 127
provision/provision.sh exists in your docker build context (on your host), but you need to copy (COPY) it first to the image:
COPY provision/provision.sh /provision/provision.sh
# or
COPY provision /provision/
RUN chmod 755 /provision/provision.sh && \
/provision/provision.sh
As mentioned in the doc:
If <src> is a directory, the entire contents of the directory are copied, including filesystem metadata.
Note: The directory itself is not copied, just its contents.
RUN will execute a command in an intermediate container launched with the Dockerfile content compiled up to that line.
It means it execute something in the context of the container, not in the context of your host.
In my case, the provision.sh file was a dos line ending file. I needed to re-save the file using Unix line endings.
I found those two answers very helpful to fix the problem:
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
at Using the RUN instruction in a Dockerfile with 'source' does not work
And this:
./configure : /bin/sh^M : bad interpreter

Resources