Why won't 'docker run' on a swarm show output from a command?

I've successfully setup a Docker Swarm cluster consisting of one master and two nodes.

Everything works as expected, only one thing deviates from the documentation. According to the docs (look for "Run a container on the Swarm") I should see the output from the command when I run something on the Swarm, but that's not what happens to me:

$ docker run hello-world   # <<< no output

$ docker ps -a
CONTAINER ID        IMAGE                COMMAND                CREATED             STATUS                     PORTS               NAMES
663f36f72ee1        hello-world:latest   "/hello"               4 seconds ago       Exited (0) 3 seconds ago                       node-1/serene_pare
...

$ docker logs 663f36f72ee1 # <<< however everything looks good
Hello from Docker.
This message shows that your installation appears to be working correctly.
...

What am I doing wrong?

UPDATE: Using run -i solves the problem. Still, I'm curious why -i is necessary with Swarm only, and why the documentation doesn't say so.

1
задан 26 April 2017 в 10:19
1 ответ

Документация неверна, и эта проблема исправляет документацию.

Флаг -i --interactive необходим потому, что флаг -i позволяет нам для создания интерактивного соединения путем захвата стандарта в (STDIN) контейнера, поскольку контейнер находится на другом хосте.

1
ответ дан 3 December 2019 в 23:49

Теги

Похожие вопросы