I created a new container from a Python:3.8 image with this command: docker run -it --name first_container -v app_files:/appfiles python:3.8
, and every time I have to run the interpreter within that container.
host@host_name:~$ docker run -it --name first_container -v app_files:/app_files python:3.8
Python 3.8.11 (default, Jun 29 2021, 19:54:56)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
I can only leave Python interpreter with exit()
or ctrl + d
. If I do that, I have to get back to the host@host_name
, not root@first_container
where I'd like to go.
>>> exit()
host@host_name:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
baf1d785d2ac python:3.8 "python3" 3 minutes ago Exited (0) 8 seconds ago first_container
What I want is to run a new container and directly get into root@first_container
to run something else. Then I can use the method from Regan to leave container without stopping it. Is this possible, or does this make any sense? (Still a newbie to docker)