Docker Community Forums

Share and learn in the Docker community.

Docker Services shutsdown once its up . How to avoid it


(bk) #1

Hello ,

I have created Docker containers using Docker-compose and ran them using docker stack deploy commands

version: "3"
    # replace username/repo:tag with your name and image details
    image: client:latest
    command: "/app/ ${hostname}"
      replicas: 3
      mode: replicated
      - "8999:8999"
      - webnet
    # replace username/repo:tag with your name and image details
    image: service:latest
      replicas: 1
      mode: replicated
      - "38080:8080"

Docker stack deploy -c docker-compose.yml sampleservice would start the services with expected replicas . Now Once the containers are up it shutsdown immediately and new containers are created and this continues throughout.

Even the file has sleep infinity placed at the end and still it goes down and new ones are created . I am unable to find the reason for the termination . I tried docker stack ps sampleservice and I dont see any details in the error column .

Please help to resolve.

Suggestion for running my app in multiple containers
(bk) #2

I just checked . If the replica service for web is 2 . Then it works fine . When I increase it it kills once the containers are up . :frowning: Any idea folks about this behaviour.

(Sam) #3

can you use

docker logs container_id

for one of the containers that ended to see if they will provide an error?

(bk) #4

I did . I dont see anything odd. :frowning: . As soon as the container is up , new containers are spinned up and old ones are removed . happening when I increase the replica to 3 fow web

(Sam) #5

did you look at the logs AFTER the container ends?

(bk) #6

Damn :cry:, In the client I am downloading a file from artifact and then start the same . Seems all of 3 containers have stopped in the miidle of the download process . :open_mouth:
i think it should be something related to timeout . As with 2 containers its able to process when I increase the timeout lapses … What you think !!

(Sam) #7

sorry, no idea… what is the source of the download? “a file from artifact”???

(bk) #8

From Jfrog-artifactory . It works fine with 2 . … strange …

(Sam) #9

ok, i have never seen a problem with artifactory like this…

i might try this manually (a script to download the artifacts) and run it multiple times concurrently to see if you can replicate the problem without containers and find the cause.

(bk) #10

I am gonna try to add this now

        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 120s

I think the window is the key to ask the engine to wait before restarting

(Sam) #11

well, that is a workaround… but not a fix… it will come back to bite you again sometime…

(bk) #12

I got the error message Exited (137) .

(bk) #13
CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
9d521c930d67        3.34%               206.2MiB / 1.795GiB   11.22%              10.1kB / 3.99kB     678MB / 470MB       50

(bk) #14

I think I caught the issue . Its with the memory . My service container takes 38% and all the 3 web takes 44.8% . So this lead to crash . Increase in my memory or maintaing it to 2 should work :slight_smile: Thanks a lot for your response .

(Sam) #15

great feedback… thanks…