1

I am trying to run interactive shell for an image which I am running using docker-compose.

I tried docker-run and docker-exec

xyz@abc:~$ sudo docker exec -it 235197ff4f0e /bin/bash
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:262: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory"

xyz@abc:~$ sudo docker run -it  drone/drone:0.7 /bin/bash
No help topic for '/bin/bash'

Trying to generate ssh key inside drone, so that i can clone from private repositories.

Shaurya Chaudhuri
  • 3,772
  • 6
  • 28
  • 58
  • The answer by @larsks is the correct answer, however, I wanted to expand on the fact that drone does not clone your repository inside the `drone/drone` image. Therefore adding an SSH key to the `drone/drone` image will not have any impact. Instead you should use drone secrets (see the official docs) to register a secret key with your repository that you can then use to clone private git+ssh repositories at runtime. Or use git+https to clone dependencies which drone typically supports with zero configuration. – Brad Rydzewski Oct 02 '17 at 20:23

1 Answers1

6

There are several things going on here. I'd like to take a look at the second error first:

The drone/drone image is configured to automatically run the /drone command (which you can determine by using docker inspect and looking for the Entrypoint key). So if you run:

docker run drone/drone:0.7 help

You end up running, inside the container:

drone help

And of course, if you run:

docker run drone/drone:0.7 /bin/bash

You are running, in the container:

drone /bin/bash

Hence the error message you are seeing ("No help topic for '/bin/bash'"), because you are passing an unrecognized option to the the drone command.


The first error is much simpler. Your error message is:

 exec: \"/bin/bash\": stat /bin/bash: no such file or directory

That seems pretty clear. There is no /bin/bash. In fact, if you inspect the contents of the image, you'll see that there is only a minimal filesystem. The easiest way to look is by starting a container, then using docker export, like this:

$ docker run drone/drone:0.7 help
[...output doesn't matter...]
$ docker export $(docker ps -lq) | tar tf -

Which shows you:

.dockerenv
dev/
dev/console
dev/pts/
dev/shm/
drone
etc/
etc/hostname
etc/hosts
etc/mtab
etc/resolv.conf
etc/ssl/
etc/ssl/certs/
etc/ssl/certs/ca-certificates.crt
proc/
sys/

There's no /bin/bash, no ssh, no git, etc, so you're not going to have much luck with your current plan. You may want to consider cloning the remote repositories on your host and then exposing them to your container using a host volume mount (-v /host/path:/container path), or building a custom image that contains the tooling you need.

larsks
  • 277,717
  • 41
  • 399
  • 399
  • This answer is spot on. Note that there is a `drone/drone:0.8-alpine` image that can be used if one needs a shell for debugging purposes. – Brad Rydzewski Oct 02 '17 at 20:15