Closed NxSoftware closed 2 years ago
This is a pretty common issue. Alpine uses musl, while Ubuntu uses glibc. Sometimes there are compatibility issues. The proper fix here is to make sure you're building on the same platform as your container will run. i.e. multi-stage builds.
However, you can also just disable CGo so that the binary isn't linked at all (also in the SO page you linked):
$ CGO_ENABLED=0 make docker
$ docker build . -t <some tag>
This means scepserver will use Go's built in DNS, user, and group resolution and probably some other stuff. I don't think any of that would affect scepserver though.
Thanks for the quick reply. I've gone with the CGO_ENABLED
flag for now but will explore setting up a multi-stage build
@NxSoftware I have a minimal example here, if you want a starting place.
When building the executables using
make docker
in Ubuntu 18.04 or 20.04 and then attempting to run the Docker container as defined by the Dockerfile (usingalpine:3
) the container immediately exits with the following error:After discovering the following Stack Overflow post it would appear that there is some dynamic linking going on and the paths are different on Alpine.
https://stackoverflow.com/questions/36279253/go-compiled-binary-wont-run-in-an-alpine-docker-container-on-ubuntu-host
I was able to solve this by adding the following line to the Dockerfile:
Though to be honest I'm not a Go developer so not sure if this is the best approach to fix the issue.