Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to get a shell from running container? #168

Closed
rezakamalifard opened this issue Mar 6, 2018 · 5 comments
Closed

Is there any way to get a shell from running container? #168

rezakamalifard opened this issue Mar 6, 2018 · 5 comments

Comments

@rezakamalifard
Copy link

Hi there,
Sometimes we need to get bash or ssh into a running container for debugging . Is it possible to do this with these images ?

@mattmoor
Copy link
Contributor

mattmoor commented Mar 6, 2018

The :debug tagged images container busybox, so you can --entrypoint=sh, but the :latest images drop this to bias towards minimal containers in production.

@rezakamalifard
Copy link
Author

rezakamalifard commented Mar 6, 2018 via email

@mattmoor
Copy link
Contributor

mattmoor commented Mar 6, 2018 via email

@dubek
Copy link

dubek commented Mar 7, 2018

@itmard You can copy the busybox into a running container and then run it there. If you have a running container named mycontainer1, you can run:

docker cp /path/to/busybox mycontainer1:/sh
docker cp /path/to/busybox mycontainer1:/ls
docker exec -it mycontainer1 /sh
# /ls
...

The busybox executable can be extracted from the busybox:latest docker image, for example. Make sure it is statically linked:

$ file busybox
busybox: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped

@dlorenc
Copy link
Contributor

dlorenc commented May 6, 2018

Closing as this looks addressed. Also see kubernetes/enhancements#277 for another take on a similar use-case.

@dlorenc dlorenc closed this as completed May 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants