简体   繁体   中英

Unable to connect to docker container

I setup two swarm manager nodes(mgr1, mgr2). But when I try to connect to the container it throws an error message .

[root@ip-10-3-2-24 ec2-user]# docker run --restart=unless-stopped -h mgr1 --name mgr1 -d -p 3375:2375 swarm manage --replication --advertise 10.3.2.24:3375 consul://10.3.2.24:8500/                

[root@ip-10-3-2-24 ec2-user]# docker exec -it mgr1 /bin/bash

rpc error: code = 2 desc = "oci runtime error: exec failed: exec: \\"/bin/bash\\": stat /bin/bash: no such file or directory"

It's happening in both the servers(mgr1, mgr2). I'm also running consul container on each node and able to connect to the consul containers.

/bin/bash might not be available there in the container. You may use sh as shown below

docker exec -it mgr1 sh or
docker exec -it mgr1 /bin/sh or
docker exec -it mgr1 bash or
docker attach mgr1

UPDATE: Based on the comments
busybox is very light weight linux based image and some of the above works perfectly fine:

bash $ sudo docker exec -it test1 bash
rpc error: code = 13 desc = invalid header field value "oci runtime error: exec failed: container_linux.go:247: starting container process caused \"exec: \\\"bash\\\": executable file not found in $PATH\"\n"
bash $ sudo docker exec -it test1 sh
/ # exit
bash $ sudo docker exec -it test1 /bin/sh
/ # exit
bash $ sudo docker attach test1
/ # exit
bash $ 

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