I have docker compose file with PostgreSQL and my application, like this:
version: '3' services: postgresql: image: postgres:9.6.6 ports: - 9932:5432 expose: - "5432" environment: - POSTGRES_PASSWORD=pass restart: always volumes: - /data:/var/lib/postgresql/data myapp: image: myapp links: - postgresql depends_on: - "postgresql" restart: always ports: - "5000:5000" The problem is that restart: always policy does not seem to work when I kill the container (simulating app crash using docker kill) and docker-compose does not restart my container, even though the Exit Code is 137. I observe the same behaviour when I use restart: on-failure policy. Versions 2 and 3 of docker-compose behave the same. My system is Ubuntu Server 16.04 x64.
My questions are:
- Why docker-compose does not restart crashed (killed) container?
- How to check if restart policy works?