1

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?

3
  • docker run a new container in parallel to the existing one, or docker exec a debugging shell, are the usual approaches; have you tried either of these? Commented Jul 27, 2020 at 13:59
  • @DavidMaze I tried docker run, it won't allow me to start a new container with the same name, so what I need to do is actually to use the existing one (and I hope to use it interactively). So the question is how to achieve that with existing docker? Commented Jul 27, 2020 at 14:01
  • Why does it need to have the same name? Is your issue just that you lose the interactive shell when your system reboots? Commented Jul 27, 2020 at 15:18

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

1

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

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.