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
- fix: https://github.com/docker/compose/issues/5016 — committed to backslash112/aws-cli-sample by backslash112 6 years ago
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.
Add -tty: true . Reference :https://docs.docker.com/compose/compose-file/
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.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
ortty: true
.My docker-compose.yml:
verbose log.txt
Would be great to know the root cause of this.
It did not work either