Docker service create interactive

My Dockerfile looks as below

FROM base-rpi:latest

USER root

WORKDIR /Pwr/murata/test

RUN make

CMD [“./murata_tcp_test”]

Docker build

docker build --no-cache --rm -t m-docker .

When I run docker as below :

docker run  -it --rm --name m-docker m-docker

it shows me interactive console and allows me to select the options

****** Test application **********
Press 1 for connect
Press 2 for add a node
Press 0 for exit
Enter choice
******************************************

But in swarm mode when I do

docker service create --name m-docker  m-docker:latest

it is unable to start docker container with below message

overall progress: 0 out of 1 tasks
1/1: preparing [=================================>                 ]
verify: Detected task failure

Docker service logs show that container is started/stopped repeatedly

docker service logs m-docker -f


m-docker.1.9gwwzx4r0isn@raspberrypi    | ****** Test application **********
m-docker.1.9gwwzx4r0isn@raspberrypi    | Press 1 for connect
m-docker.1.9gwwzx4r0isn@raspberrypi    | Press 2 for add a node
m-docker.1.kpg4fxom4uyw@raspberrypi    | ****** Test application **********
m-docker.1.kpg4fxom4uyw@raspberrypi    | Press 1 for connect
m-docker.1.kpg4fxom4uyw@raspberrypi    | Press 2 for add a node
m-docker.1.9gwwzx4r0isn@raspberrypi    | Press 0 for exit
m-docker.1.9gwwzx4r0isn@raspberrypi    | Enter choice
m-docker.1.kpg4fxom4uyw@raspberrypi    | Press 0 for exit
m-docker.1.kpg4fxom4uyw@raspberrypi    | Enter choice
m-docker.1.tk676t1aabmh@raspberrypi    | ****** Test application **********

How to run docker service create in interactive mode . I referred the docker service create documentation but it doesnot provide any option to run in interactive mode

In the context of a service, interactive mode is tricky. Services are, by definition, scalable, which means that at any time, a user can increase or decrease the number of instances running on the node or cluster; it’s also possible to scale services to 0 instances/tasks. So, if you were to create an interactive service, which task or container would you interact with? Or, if you intend to only ever have one instance of the image running on your cluster or node, why attempt to create a service?

All that said, the docker service create command does support the -t option to instantiate a TTY. However, the traditional -i option is not supported.

So, if you are considering creating your service and scaling it at some point, you may want to consider a different design approach. Or, you may want to consider running single containers in interactive mode (without using a service), or using environment variables or configuration files or some other method to communicate the endpoint the code should work with.