I have a Go service that references a C library, and I am getting the following error when trying to run my docker image:
standard_init_linux.go:228: exec user process caused: no such file or directory
This is not a duplicate of standard_init_linux.go:190: exec user process caused "no such file or directory" - Docker as I do not have an entrypoint shell script with CR line endings. Some others on this site suggested setting CGO_ENABLED=0
at compile time, but I of course can't do that as this is a CGO project.
The C library is installed under /usr/local/lib/sgp4
in the directories Linux/IFORT
and Linux/GFORTRAN
, which contain a bunch of .so files.
An environment variable LD_LIBRARY_PATH is set to /usr/local/lib/sgp4/Linux/IFORT.
Within my project, there is a set of wrapper .h files, and the CGO comments as follows:
My Dockerfile is as follows:
FROM [redacted]/alpine-base:3.17
RUN apk update && \
apk add curl jq
COPY etc/cfg/propagator.properties /usr/local/[redacted]/etc/cfg/
COPY bin/sgp4 /usr/local/[redacted]/bin/sgp4
COPY propagator/wrappers /usr/local/[redacted]/bin/wrappers
# Download library files
RUN mkdir -p /usr/local/sgp4/lib
RUN curl --output /usr/local/sgp4/lib/SGP4.tar [redacted]/SGP4.tar
RUN tar -xf /usr/local/sgp4/lib/SGP4.tar -C /usr/local/sgp4/lib
RUN rm /usr/local/sgp4/lib/SGP4.tar
RUN export LD_LIBRARY_PATH=/usr/local/sgp4/lib/Linux/IFORT
RUN chmod a+rx /usr/local/[redacted]/bin/sgp4
RUN addgroup [redacted] && adduser -D -H -G [redacted] [redacted]
USER [redacted]:[redacted]
HEALTHCHECK NONE
ENTRYPOINT ["/usr/local/[redacted]/bin/sgp4", "-config-file-path=/usr/local/[redacted]/etc/cfg/propagator.properties"]
Wondering if my library files contained CR line endings, I tried adding these commands to my Dockerfile, but no luck:
RUN for filey in $(find /usr/local/sgp4/lib/Linux -type f); do echo $filey; sed -i 's/\r$//g' $filey; done
RUN for filey in $(find /usr/local/sgp4/lib/Linux -type f); do echo $filey; tr -d \r < $filey > tmp.so; mv tmp.so $filey; done
Note: I compiled the binary on debian, but am constrained to using Alpine for the Docker image. Issues I encountered when compiling are discussed here: cgo compiler error, missing library links, librt.so.1 not found