compose: Container stops immediately with docker-compose but runs fine with Docker.

I have two services and each service calls dockerfile which has microsoft/windowsservercore as a base image. When I run docker-compose up on windows, the containers are getting stopped immediately however same yaml file on linux keeps containers running. is there any known issue on windows?

my docker-compose.yml file is:

version: '3'

networks:
  default:
    external:
      name: nat

services:
  awi-service:
    env_file:
      - awi-box.env
    image: awi-box:12.0.0
    ports:
    - 8080:8080
    depends_on:
    - ae-service
    

  ae-service:
    env_file:
      - ae-box.env
    image: ar-box:12.0.0
    ports:
    -  2217:2217
    -  2218:2218

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 20

Commits related to this issue

Most upvoted comments

After I have added stdin_open: true and tty: true to compose file, I can see the container is up and running.

We can close this issue unless there is any other solution available for this.

Did you check the logs of your services? What is their exit code? Does docker-compose --verbose up give you any additional information?

None of them worked for me (tty or stdin_open). I am using Mac OS 10.12.6. and I have tried docker-compose version 2 and 3.

Thanks, @vanquangthanhhao . Actually I found what could be the real cause: my container only has a simple launch script, so once the launch script finished, the container exit with 0. To avoid that, I add a long running command at the end, such as ping localhost, and then the instance stays alive.

capture I think that you add a running command at the end will increase workload if you run container a long time.

I experienced this same issue as well. I can run it using docker run just fine but docker-compose up gives exit code 0 for one of my services. I’m using a macbook and what made it work was EITHER stdin_open: true or tty: true.

My docker-compose.yml:

komuniki-mongo:
  image: mongo
  container_name: "komuniki-mongo"
  volumes:
    - ./temp/mongo_backups:/data/db/mongo_backups
  ports:
    - '27017:27017'

app:
  mem_limit: 300m
  memswap_limit: 1g
  container_name: "komuniki"
  build: .
  volumes:
    - .:/home/nodejs/app
    - ./node_modules:/home/nodejs/app/node_modules
  ports:
    - '7000:7000'
  links:
    - komuniki-mongo:mongo

verbose log.txt

Would be great to know the root cause of this.

capture I think that you add a running command at the end will increase workload if you run container a long time.

It did not work either