Bare OS containers in swarm are unable to stay in a running state

Hello,

I have run into an issue with spinning up containers for certain images within the context of a swarm. Specifically, bare OS containers alternate between running and shutdown states when I use them in a stack. I have no issues running the same images as stand alone containers either in interactive or detached mode. I don’t have this issue with database images like redis, mongo, or other services like nats-streaming.

For instance the following .yml script is able to spin up a swarm without issue:

version: '3.7'
services:
  nats:
    networks:
      - net
    image: nats-streaming
    configs:
      - nats_config
  mongo:
    networks:
      - net
    image: mongo
    configs:
      - mongo_config
networks:
  net:
configs:
  nats_config:
    file: ../nats.conf
  mongo_config:
    file: ../mongod.conf

However, the script below results in the ubuntu container starting up and shutting down repeatedly.

version: '3.7'
services:
  master:
    networks: 
      - net
    image: ubuntu
    ports:
      - 9000:9000
  nats:
    networks:
      - net
    image: nats-streaming
    configs:
      - nats_config
  mongo:
    networks:
      - net
    image: mongo
    configs:
      - mongo_config
networks:
  net:
configs:
  nats_config:
    file: ../nats.conf
  mongo_config:
    file: ../mongod.conf

The only difference is I have added another container in the stack. If I were to replace the ubuntu image with redis or postgres I would not have an issue.

Thanks!

What makes you expect that your “master” service, using a naked ubuntu image, would keep on running?

Hello,

Thank you for your response.

It runs without issue if I spin it up at as stand alone container using the docker run command. I know I am missing something when it comes to deploying stacks. What can I do to set up the master service so that it remains in a Running state?

Thanks!