micromamba-docker icon indicating copy to clipboard operation
micromamba-docker copied to clipboard

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

Open gdevenyi opened this issue 2 years ago • 3 comments

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

gdevenyi avatar Oct 02 '23 14:10 gdevenyi

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?

wholtz avatar Oct 02 '23 17:10 wholtz

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

gdevenyi avatar Oct 02 '23 18:10 gdevenyi

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....

wholtz avatar Oct 03 '23 03:10 wholtz