open-horizon-services / web-helloworld-c

Hello World Open Horizon service container implemented in C
Apache License 2.0
1 stars 4 forks source link

Defective Docker Issue #12

Closed julianchen215 closed 2 years ago

julianchen215 commented 2 years ago

Getting this message when trying to build the docker file:

Successfully built df2db614b282 Successfully tagged ibmosquito/web-hello-c:1.0.0 docker rm -f web-hello-c 2>/dev/null || : docker run -it --name web-hello-c -p 8000:8000 --volume pwd:/outside ibmosquito/web-hello-c:1.0.0 /bin/bash docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown. ERRO[0000] error waiting for container: context canceled make: *** [Makefile:14: dev] Error 127

joewxboy commented 2 years ago

@t-fine and @johnwalicki I'm not sure if there is an error in the Dockerfile or it is some peculiarity of performing a Docker build within WSL 2 due to limited OCI support, but running make build is failing with the above error for @julianchen215 in WSL 2.

NOTE: We followed @TheMosquito instructions for configuring systemd in WSL 2, and then successfully installed the agent and registered it with the LF Edge lab exchange instance. Then after cloning this repo, we ran make dev and it failed at the very end of building the Docker image.

johnwalicki commented 2 years ago

The docker build was successful.

dev: build stop
    docker run -it --name $(NAME) -p $(PORT):$(PORT) --volume `pwd`:/outside $(DOCKER_HUB_ID)/$(NAME):$(VERSION) /bin/bash

fails on the interactive docker run /bin/bash because this is a

FROM scratch 

container (see the Dockerfile) that does not have bash.

We should delete the make dev rule. It will never work.

To test, you need to docker log -f the running detached container.

johnwalicki commented 2 years ago

To be clear, The bug is not in the Dockerfile. The bug is in the Makefile.

johnwalicki commented 2 years ago

If you want to keep the dev: stanza, do this:

Change the -it to -d

docker run -d --name $(NAME) ...
docker logs -f $(NAME)
johnwalicki commented 2 years ago

Mostly fixed by #11 Although the make exec rule should be removed because it tries to run /bin/bash on a scratch container (that does not include bash.

$ make -n exec
docker exec -it web-hello-c /bin/bash