How to enter in a Docker container already running with a new TTY

前端 未结 11 1371
你的背包
你的背包 2020-11-29 14:20

I have a container that is running the Apache service in the foreground. I would like to be able to access the container from another shell in order to \"poke around\" insid

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 15:04

    First step get container id:

    docker ps

    This will show you something like

    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

    1170fe9e9460 localhost:5000/python:env-7e847468c4d73a0f35e9c5164046ad88 "./run_notebook.sh" 26 seconds ago Up 25 seconds 0.0.0.0:8989->9999/tcp SLURM_TASK-303337_0

    1170fe9e9460 is the container id in this case.

    Second, enter the docker :

    docker exec -it [container_id] bash

    so in the above case: docker exec -it 1170fe9e9460 bash

提交回复
热议问题