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

Properly document how to launch a shell in an image, not just a running container #374

Open
gdevenyi opened this issue Oct 2, 2023 · 3 comments

Comments

@gdevenyi
Copy link

gdevenyi commented Oct 2, 2023

The documentation lists how to properly use docker exec however it doesn't list how to get a shell in an image.

@wholtz
Copy link
Member

wholtz commented Oct 2, 2023

Hi @gdevenyi .

I'm not completely sure I understand the request. Are you looking for documentation of this:

docker exec -it <container> /bin/bash

or something else?

@gdevenyi
Copy link
Author

gdevenyi commented Oct 2, 2023

Are you looking for documentation of this:

No, I'm looking for documentation on how to get a shell in a non-running container (aka an image), where the default entrypoint has been overridden (ENTRYPOINT ["/usr/local/bin/_entrypoint.sh", "anothercommand"]), such that I get the proper container environment.

After much experimenting and reading the existing dockerfile, I think this is what I need to override:

$ docker run -it --entrypoint /usr/local/bin/_entrypoint.sh <mycontainerimage> /bin/bash

@wholtz
Copy link
Member

wholtz commented Oct 3, 2023

Yes, if you set a new ENTRYPOINT in a derived image and then you want to get back to the old ENTRYPOINT you can specify the old ENTRYPOINT on the command line:

$ docker run -it --entrypoint /usr/local/bin/_entrypoint.sh <mycontainerimage> /bin/bash

and if you are still using the default (or root) user you can even get away with:

$ docker run -it --entrypoint /bin/bash <mycontainerimage>

As the .bashrc for that user will activate the environment.

I will think about how this would best fit into the documentation. PRs are welcome of course....

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

2 participants