Docker Community Forums

Share and learn in the Docker community.

Help debugging "[8] System error: no such file or directory"


(Christopher Harvey) #1

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.

Thanks.


(Joe) #2

Hi,

You can debug this using the following steps:

  • Comment out the CMD line in the Dockerfile
  • Now using this new Dockerfile create an image called “main_in_scratch”
  • Run this command: docker run -it main_in_scratch /bin/bash
  • Once inside the Container, say “/usr/local/bin/main” and see what you get.

Cheers,
Joe


(Christopher Harvey) #3

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.


(Joe) #4

Hi Christopher,

I understand your confusion.

I was under the impression that the base image “scratch” was a Linux Distro with shell in it. Looks like it is not.

Here is what I suggest you do:

  • Which Linux Distro is this single C++ executable called “main” supposed to run on? Ubuntu, Fedora, Debian etc?
  • If it is Ubuntu, then in your Dockerfile, set the arg for the FROM instruction as ubuntu
  • Now follow the steps I mentioned previously

That should help you debug. Cheers.

-Joe


(Christopher Harvey) #5

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.


(Jonh2015) #6

Can you show us what the correct dockerfile is now? That will help those of us hitting the same issue.


(Christopher Harvey) #7

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.