Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to ssh docker container

Tags:

docker

ssh

I am running the container hypriot/rpi-busybox-httpd

I am trying to ssh to docker container: but it is giving error :

pi@raspberrypi:~ $ docker exec -it cc55da85b915 bash rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"bash\": executable file not found in $PATH"  pi@raspberrypi:~ $ docker exec -it cc55da85b915 sh rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"sh\": executable file not found in $PATH" 

am I doing the right away ?

like image 279
Ciasto piekarz Avatar asked Feb 04 '17 20:02

Ciasto piekarz


People also ask

How do I connect to docker container terminal?

To connect to a container using plain docker commands, you can use docker exec and docker attach . docker exec is a lot more popular because you can run a new command that allows you to spawn a new shell. You can check processes, files and operate like in your local environment.


2 Answers

The image you're using seems that it doesn't have the binary /bin/bash installed but it should have /bin/sh

Try:

docker exec -it cc55da85b915 sh 
like image 37
Alaeddine Avatar answered Oct 02 '22 17:10

Alaeddine


It could be your image does not have the binary /bin/bash installed (as suggested before), I had the same problem and I was able to enter into the container using /bin/sh

docker exec -ti cc55da85b915 /bin/sh 

Another workaround could be execute directly the commands without get access to any shell.

docker exec -ti cc55da85b915 ls /etc 
like image 187
Esteban Collado Avatar answered Oct 02 '22 17:10

Esteban Collado