简体   繁体   中英

Running Docker Interactive Shell

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM