bash - Docker - ssh by container name -


i want easy ssh docker container container name. ssh container need call:

docker ps 

which returns:

container id        image <container_id>        mycontainer 

and copy container_id execute command:

docker exec -ti <container_id> /bin/bash/ 

i have many containers , easier ssh image name. possible without writting custom bash script?

in general, long don't install ssh client inside every container no, not possible "ssh" inside container.

please note can use container name instead of container id exec command (/bin/bash in case) running container.

for example, given container this:

$ docker ps container id        image                                   command                  created             status              ports                              names 5b3068b4e51c        registry_registry                       "/entrypoint.sh /e..."   4 months ago        2 hours          0.0.0.0:5000->5000/tcp             registry_registry_1 

running following 2 command leads same result:

docker exec -ti 5b3068b4e51c /bin/bash docker exec -ti registry_registry_1 /bin/bash 

furthermore, again in general, have more 1 container running same image, want achive (enter container image name) isn't safe.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -