J
J
Jordan_Belforts2020-02-13 10:40:31
Docker
Jordan_Belforts, 2020-02-13 10:40:31

For what reason can the container in docker not start?

I installed the ubuntu server, as well as the docker, then with the command sudo docker run -d ubuntu installed the container. Now I enter the command sudo docker ps and in response I get only this line

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

please tell me why is that?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2020-02-13
@Jordan_Belforts

The container starts and immediately closes.
Because by default, the command is executed there /bin/bash, which, without a terminal, immediately ends execution.
You run the container in daemon mode (key -d)
If there were not bashsome long-running command, mysqld or nginx, everything would work longer.
Probably, you need to start the container and "be" in its shell:
docker run -it --rm ubuntu

  • -iinteractive mode
  • -tconnects a virtual terminal
  • --rmwill delete the container as soon as you exit it

Here are two options to start Ubuntu so that the container remains hanging:
docker run -d ubuntu tail -f /dev/null- here is a dummy command that will run indefinitely;
docker run -t -d ubuntu- a virtual terminal is connected here and bash will not crash, but will remain running.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question