Attaching to a docker container with base image scratch?
docker
Solution
You need to add a shell to your empty base image (SCRATCH) in order to attach to it.
Right now, your image only include an executable, which is not enough.
As mentioned in issue 17896
`FROM scratch` literally is an empty, zero-byte image `/` filesystem, where you add everything yourself. See for example, the `hello-world` which, produces an image that's 860 bytes total.
If you need a shell to attach to it through docker exec, start from a small image like Alpine (which has only `/bin/sh` though: you would need `apk add bash` to add `bash`, as commented below by user2915097).
Problem
I have a docker file as follows: ``` FROM scratch ARG VERSION=NOT_SET ENV VERSION $VERSION COPY foobar foobar COPY foobar-*.yaml /etc/ COPY jwt/ /etc/jwt/ EXPOSE 8082 ENTRYPOINT ["./foobar"] CMD ["-config", "/etc/foobar-local.yaml"] ``` Now, docker ps shows the following: ``` CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 653a9b287eb6 7693481.dkr.ecr.us-east-1.amazonaws.com/foobar:0.0.1 "./foobar -config /e" About a minute ago Up About a minute foobar ``` When I try to exec to this container with the following command: ``` sudo docker exec -it 653a9b287eb6 /bin/bash ``` it shows the following error: ``` rpc error: code = 2 desc = oci runtime error: exec failed: exec: "/bin/bash": stat /bin/bash: no such file or directory ```