Help: Trying to build a minimal hello world example docker container

I have a basic hello world app that I'm trying to deploy to a docker container.

I have even tried to set the target to musl so that it's completely statically linked.

However, I'm unable to make the container run.

Here's the minimal reproduction:

I would really appreciate any help in making this work.

After cloning the repo and ensuring you have a working Cargo and Docker setup, try running the build.sh file in the project root. It fails for me. Any thoughts on what I'm missing?

When I run build.sh, this is what I see:
image

Been struggling with this for over a day. Any help is appreciated. Thank you :slightly_smiling_face:

Please run cargo clean and try again. The binary hello_world should only be inside target/x86_64-unknown-linux-musl/release, not in target/release

2 Likes

the Dockerfile looks fine to me. from the screenshot it seems the build is successful. so I guess there might be a problem of loading the image.

first check the images, e.g. what's the output of docker images? pay attention to the CREATED column, is the hello_world:latest image the right image you just build?

you may try to add --load command line option to docker build.

This was it. What a silly mistake to make. Thank you

I was originally trying to make this work so that I could proceed to the next step which is to compile an axum project to work inside a docker container.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.