Reputation: 3678
I have a docker-compose file that controls a few services. One of which are a db service. I don't always want to restart the db service.
Example docker-compose.yml:
version: '3'
services:
base:
commad: "echo somecommand"
postgres:
container_name: postgres
image: "postgres:latest"
environment:
- POSTGRES_PASSWORD=usr
- POSTGRES_USER=use
- POSTGRES_DB=usr
ports:
- 5432:5432
How can I do docker-compose up
, but if the db service (postgres in my case) is already up, making sure it wont restart.
Im currently using docker-compose down/up, and my db restarts.
I tried to add --scale postgres=0
to my docker-compose up command, but then it shuts down postgres all together.
Upvotes: 7
Views: 4800
Reputation: 12079
Use docker-compose up --no-recreate
.
Ref https://docs.docker.com/compose/reference/up/
Upvotes: 14