I’ve got a container with a single executable (c++) in it (created from the scratch image) and it’s dependencies located in /usr/lib. When I run the container with “docker run -ti img_name” I get the following output:
no such file or directory
Error response from daemon: Cannot start container ccca56c522d3d529254f080099846fc62bacdb2687b4ef559038b2f873a049cd: [8] System error: no such file or directory
Here is what my Dockerfile looks like:
FROM scratch
COPY main /usr/local/bin/main
COPY fs /
EXPOSE 55555
CMD ["/usr/local/bin/main"]
It would be really helpful if it could tell me what file it couldn’t find without having to resort to strace. The “main” program runs fine when statically linked, or when added to a full blown image like ubuntu.
I’m confused, since you say to create an image from scratch wouldn’t that mean there is no /bin/bash binary to execute? Running those commands blindly obviously outputs this:
exec: “/bin/bash”: stat /bin/bash: no such file or directory
Error response from daemon: Cannot start container 78cb9a9bc24737cb8b2adca48491bc4a254f6c3f05ede115dab0e497cffca70a: [8] System error: exec: “/bin/bash”: stat /bin/bash: no such file or directory
I’m guessing I’m not understanding what you really wanted me to do.
Turns out I needed to include the linux loader in the docker image. I assumed that the docker programs were loaded by the host machine. I guess I still have a bit to learn about how docker interacts with the kernel.
For anybody else reading this the loader is this file on my PC:
/lib64/ld-linux-x86-64.so.2
now if I’m missing a dependency it’s printed in full.
I would, but it’s so specific to my system…the key here is to use the COPY command to copy your loader into the image. Where that loader comes from is specific to your system, and what loader you pick is also a choice the developer has to make. Normally the loader comes from the FROM command, if you use FROM scratch, then just be sure to remember to COPY a loader in instead.