简体   繁体   中英

Run interactively with existing docker container

I have a container started as the following:

docker run --interactive --tty --gpus all --name my_container 
--workdir "/home/ubuntu" --user ubuntu 
--volume /hdd/all_cv/paiv/metis:/home/ubuntu/my --publish 8888:8888 my

how do I run interactively with my_container once I reboot my machine?

Based on the docker documentation , you can attach back to the detached container using docker attach command:

Use docker attach to attach your terminal's standard input, output, and error (or any combination of the three) to a running container using the container's ID or name. This allows you to view its ongoing output or to control it interactively, as though the commands were running directly in your terminal.

So you should try this to have an interactive session with your already running container:

docker attach my_container

If your container is stopped, you just need to start it again

docker ps -aq -f name=my_container | xargs docker start $1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM