Zaks
Zaks

Reputation: 700

docker service create interactive mode

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

Upvotes: 2

Views: 1179

Answers (1)

Adiii
Adiii

Reputation: 59936

That because of swarm, it runs container by default in detach mode, so no tty will be allocated to interact with container.

Did you tried to run with

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

This will allocate pseudo-TTY

--tty , -t      API 1.25+   Allocate a pseudo-TTY

service_create

Upvotes: 1

Related Questions