Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERRO[0001] error waiting for container: context canceled

Getting error while running docker image. It seems to look like the problem is on my pc.

I'm using MacOS 10.13.6. I have followed steps to create a docker image.

Sanjeet:server-api sanjeet$ docker build -t apicontainer .

Sending build context to Docker daemon  24.01MB
Step 1/2 : FROM alpine:3.6
 ---> da579b235e92
Step 2/2 : CMD ["/bin/bash"]
 ---> Running in f43fa95302d4
Removing intermediate container f43fa95302d4
 ---> 64d0b47af4df
Successfully built 64d0b47af4df
Successfully tagged apicontainer:latest

Sanjeet:server-api sanjeet$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
apicontainer        latest              64d0b47af4df        3 minutes ago       4.03MB
alpine              3.6                 da579b235e92        2 weeks ago         4.03MB

Sanjeet:server-api sanjeet$ docker run -it apicontainer

docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown.
Sanjeet:server-api sanjeet$ ERRO[0001] error waiting for container: context canceled 

Inside Dockerfile

FROM alpine:3.6

CMD ["/bin/bash"]
like image 998
Sanjeet kumar Avatar asked Jul 22 '18 19:07

Sanjeet kumar


3 Answers

alpine does not include bash by default. If you want to include bash, you should add RUN apk add --no-cache bash in your Dockerfile.

like image 116
sachav Avatar answered Nov 06 '22 23:11

sachav


Issues while running/re-initialize Docker

ERRO[0000] error waiting for the container: context canceled

Steps to Stop the Running Docker Container Forcefully

docker ps
//copy the CONTAINER ID of the running process, ex: CONTAINER ID: 37146513b713
docker kill 37146513b713
docker rm 37146513b713
like image 2
Manish Kumar Singh Avatar answered Nov 07 '22 00:11

Manish Kumar Singh


alpine does not provide glibc. alpine is that small because it uses a stripped down version of libstdc called musl.libc.org.

So we'll check statically linked dependencies using ldd command.

$ docker run -it <image name> /bin/sh
$ cd /go/bin
$ ldd scratch

Check the linked static files, do they exist on that version of alpine? If the do not from, the binaries perspective, it did not find the file-- and will report File not found.

The following step depends on what binaries were missing, you can look it up on the internet on how to install them.

Add RUN apk add --no-cache libc6-compat to your Dockerfile to add libstdc in some Golang alpine image based Dockerfiles.

In you case the solution is to either

  • disable CGO : use CGO_ENABLED=0 while building
  • or add RUN apk add --no-cache libc6-compat to your Dockerfile
  • or do not use golang:alpine
like image 1
frozenOne Avatar answered Nov 07 '22 00:11

frozenOne