Problem building and deploying as Docker #377
Unanswered
Enterprise76
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am new to the Go language and an amateur with Docker so bear with me. I am trying to make a small edit to the source code, compile in Go, and then Deploy as a Docker image.
For simplicity, I am doing the following on a clean fork of the original code... so no edits made yet.
Here are the steps I am doing:
cmd/podsync
I am runninggo build
. This successfully builds the executable podsync which runs correctly when passed a valid config.toml file. It appears to download a file in my config.toml, so I am assuming this is the correct way to compile podsync.sudo docker build .
. This appears to build successfully.Then, when I run
sudo docker run -p 8080:80 [container name]
I get the following error:exec /app/podsync: no such file or directory
. I have done this with or without adding volumes with the same effect.This is odd, because when building the Dockerfile it seems to sucessfully copy the binary
...
Step 4/6 : COPY podsync /app/podsync
...
This is my first attempt at both Go language, and building a custom Docker
image.
Is there anything fundamentally wrong with the way I am building either? Any idea why the Docker image appears to build correctly, yet the entrypoint cannot be found when I run the image in a container?EDIT
Upon further investigation, I have found that the podsync executable is in the docker image by using -it entrypoint sh when launching the container. The problem is that this executable cannot be launched from within the container.
ls -lia /app
...
310 -rwxr-xr-x 1 root root 22.0M Aug 8 18:05 podsync
...
Running
./podsync
in the container results insh: ./podsync: not found
.However, running
./podsync
in the public docker image from docker hub (mxpv/podsync) successfully launches the executable.There is some reason this executable runs outside of docker, but not in docker. Could this be an issue with my build environment? I'm building on Ubuntu 22.04, but the Dockerfile builds with Alpine. Is there a way for me to compile this in an Alpine build environment?
SOLVED
After a bunch of research, I found that a go binary compiled on Ubuntu will sometimes react as if it was not found on Alpine.
I modified the Dockerfile in a fork which will rebuild the application (run go build) in Alpine each time the Docker image is created. Simply make code edits, create a new Docker image, and deploy. My first forray into go and Docker appears to be working for now...
Thanks for any ideas, and thanks to everyone for contributing to this project.
Mike
Beta Was this translation helpful? Give feedback.
All reactions