Binary Application Runs In VirtualBox VMs, not in Docker Containers: "No such file or directory"

I’m trying to run a binary within a docker swarm, following along in the Docker tutorial:

I’ve verified that the binary actually executes as expected when I launch the docker machines’ hosts within VirtualBox and execute the binary from the guest Ubuntu CLI. How can I get more info about why my app exits when run inside a container, but not from the CLI of the guest VM?

Dockerfile:
FROM scratch
WORKDIR /bin
COPY . /bin/
EXPOSE 8000
ENV NAME World
CMD ["./app"]

docker-compose.yaml:
version: “3”
services:
web:
image: tamborello/get-started:lisp-app
deploy:
replicas: 2
resources:
limits:
cpus: “0.1”
memory: 50M
restart_policy:
condition: on-failure

Do I need this statement if I’m not remapping ports?

ports:
 - "8000:8000"
networks:
 - webnet

networks:
webnet:

However, when I attempt to deploy to the swarm, the application apparently exits immediately. Furthermore, there should only be two nodes, but I get many more IDs indicated.

Squid:Ex2 frank$ docker stack deploy -c docker-compose.yml hello-lisp
Updating service hello-lisp_web (id: q7o7g5e7u575ldu12tuqilxs4)
Squid:Ex2 frank$ docker stack ps hello-lisp
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
iv0fxkxvfl0o hello-lisp_web.1 tamborello/get-started:lisp-app slab Ready Ready 3 seconds ago
mps39h4ehfmk _ hello-lisp_web.1 tamborello/get-started:lisp-app donk Shutdown Failed 3 seconds ago “task: non-zero exit (1)”
smck0kngmm0p _ hello-lisp_web.1 tamborello/get-started:lisp-app donk Shutdown Failed 10 seconds ago “task: non-zero exit (1)”
hkxzsvcd15v7 _ hello-lisp_web.1 tamborello/get-started:lisp-app donk Shutdown Failed 16 seconds ago “task: non-zero exit (1)”
timrdxrbfpag _ hello-lisp_web.1 tamborello/get-started:lisp-app donk Shutdown Failed 22 seconds ago “task: non-zero exit (1)”
pb74s7p7c1zc hello-lisp_web.2 tamborello/get-started:lisp-app donk Ready Ready 3 seconds ago
wxnupb6kx6qx _ hello-lisp_web.2 tamborello/get-started:lisp-app slab Shutdown Failed 3 seconds ago “task: non-zero exit (1)”
y5cpulsnt9nc _ hello-lisp_web.2 tamborello/get-started:lisp-app slab Shutdown Failed 9 seconds ago “task: non-zero exit (1)”
tnyswuuisscn _ hello-lisp_web.2 tamborello/get-started:lisp-app slab Shutdown Failed 15 seconds ago “task: non-zero exit (1)”
rfyzl9qp6wjn _ hello-lisp_web.2 tamborello/get-started:lisp-app slab Shutdown Failed 22 seconds ago “task: non-zero exit (1)”

Squid:Ex2 frank$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Squid:Ex2 frank$ docker service logs hello-lisp_web
hello-lisp_web.2.reu7k2v8iylx@slab | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.1.4cjg96wcm4yd@slab | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.2.65iv87sbcdjy@donk | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.1.kwuvgjvnldvl@donk | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.2.995952efkzvr@donk | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.1.ly3v0m0qgtls@donk | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.2.6trjw2eg9bic@donk | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.1.333spbndcng8@donk | standard_init_linux.go:190: exec user process caused “no such file or directory”

Squid:Ex2 frank$ docker service logs hello-lisp_web
hello-lisp_web.1.v5cpqznvkgw5@donk | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.1.qrk2hy4gbwy7@donk | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.1.sgpm87slzr7j@donk | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.2.pulbq8dsuzy1@donk | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.2.taitrdq7rq15@donk | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.1.cxb7evvh2wd6@slab | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.2.cyuw78nm8yst@slab | standard_init_linux.go:190: exec user process caused “no such file or directory”
hello-lisp_web.2.rpre3j9eeeqi@slab | standard_init_linux.go:190: exec user process caused “no such file or directory”

You can debug your docker image by doing a

docker container run -it tamborello/get-started:lisp-app

And see the errors.

Then you can bring up a command prompt and snoop around to figure out why it failed.

docker container run -it tamborello/get-started:lisp-app sh

Regarding this:

However, when I attempt to deploy to the swarm, the application apparently exits immediately. Furthermore, there should only be two nodes, but I get many more IDs indicated.

docker is attempting to restart the services and will continue to do so because they are failing.

Regarding this:

ports:
 - "8000:8000"

That publishes the port so it is reachable from the Docker Node.

1 Like

Ah, I just saw that your image is being built from scratch which means it has nothing, not even shells.
So, the error you are getting is:

hello-lisp_web.2.995952efkzvr@donk | standard_init_linux.go:190: exec user process caused “no such file or directory”.

I’m thinking it can’t find your command ./app and that’s the error.

I would change the FROM statement in your Dockerfile temporarily to use alpine or ubuntu, rebuild your image and run it in a container and then debug it. That way you can get a sh prompt. Same instructions as I posted before to debug. Once you debug it, you can go back and use the scratch image.

Another possibility is that maybe the platform and architecture of the machine where you actually built your application does not match the platform and architecture of the Docker node where you are trying to run the application. Your are not actually “building” your application in your Dockerfile. You are copying the binary. So verify this too.