1

I have written my own simple docker image. It works fine.

Then I created my docker swarm with only two nodes a master and a slave and started a service with the following command:

docker service create --mode global --name benchmark briomkez/ethereum-test

It loops, because it cannot create the service (the default command is a simple ls).

Why does this happen? Is it expected?

If I run the same service with a different command, e.g.:

docker service create --mode global --name benchmark briomkez/ethereum-test geth

It works like a charm. Is this behavior expected, what is the motivation for the loop?

1 Answer 1

1

Docker containers are isolated applications. When the application that it launches exits, the container also exits. So when your command is ls, that will run and then exit almost immediately, stopping the container.

Swarm mode has the goal to maintain a target state for your containers. By default, it will keep a single replica (instance of a container) of the service running. If the current state does not match the target state, it will take action to correct the issue. So for a container that has no running instances and a target replica count of 1, it will be constantly started.

So yes, this is an expected behavior given the inputs. Instead of ls, you should be using a long running daemon process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.