william007
william007

Reputation: 18547

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?

Upvotes: 1

Views: 1624

Answers (2)

Sergio Tanaka
Sergio Tanaka

Reputation: 1435

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

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

Upvotes: 1

Reza Behzadpour
Reza Behzadpour

Reputation: 714

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

Upvotes: 1

Related Questions