Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bring a running docker container again foreground

Tags:

docker

I have a docker container running

sudo docker ps -a

result:

CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS                PORTS               NAMES
0cd8d5166717        32bit/ubuntu:14.04   /bin/bash           15 hours ago        Up About an hour                        hadoop-test        

How can I bring this running container again to -it mode and grab the terminal of ubuntu system ?

like image 292
Hello lad Avatar asked Dec 08 '14 13:12

Hello lad


People also ask

How do I run a docker image in foreground?

Typically, commands that run in the foreground should use the --rm flag so that the container is cleaned up after the command has completed. If you are testing a long-running command, typing Ctrl+C will exit out of the container. In order to run a container in the background, use the -d flag.

How do I keep my docker container running after ENTRYPOINT?

The simplest way to keep the container running is to pass a command that never ends. We can use never-ending commands in any of the following ways: ENTRYPOINT or CMD directive in the Dockerfile. Overriding ENTRYPOINT or CMD in the docker run command.

How do I run a docker image again?

To restart an existing container, we'll use the start command with the -a flag to attach to it and the -i flag to make it interactive, followed by either the container ID or name. Be sure to substitute the ID of your container in the command below: docker start -ai 11cc47339ee1.

How do you rerun an exited container?

Enter the docker start command with the Container ID in the command line to resume the Container. Note: This preserves environment variables set during the initial docker run statement.


1 Answers

You can attach it:

docker attach 0cd8d5166717

Type Ctrl-PCtrl-Q to detach it again.

like image 62
kev Avatar answered Oct 21 '22 11:10

kev