2

I have docker-compose file that runs 4 services:

  • web
  • db
  • redis
  • selenium

I would like the containers of services redis and selenium to always start fresh when I execute docker-compose, while preserving the state of web and db.

I don't mind if this is achieved destroyng the containers on exit or recreating new ones on start. At the moment I run this command:

docker-compose rm selenium && docker-compose rm redis && docker-compose up

I would prefer to have the same behavior using the docker-compose.yml file, instead of the command line.

1 Answer 1

2

You can use docker-compose --force-recreate flag when executing up, to always recreate containers and configure volumes to persist databases data (on a local directory or a docker volume).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.