Reputation: 1413
A have few projects on my computer, that all are developed.
I started working with docker few month ago and I share some config between projects.
I have clear container list each time. Why? Because usually my process need to look like:
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
docker-compose up -d
The problem is everywhere, I have defined composer (like in config below). When I switch, but don't delete images/containers, then i have, that composer/composer
container exist and don't start.
Of course, I use more services like that, but this is simples one.
version: '2'
services:
php:
image: php:7.1.3-alpine
volumes:
- ./:/app
working_dir: /app
composer:
image: composer/composer
volumes_from:
- php
working_dir: /app
Docker multi use of containers
/ docker multi projects on local with same container
As the topic is to wide, to many pages. Maybe I ommited something in understand of concept or config.
Would be nice to get some explanation and hints for good manage docker-compose.yml
files like that and what was wrong in my process.
Thanks.
Upvotes: 0
Views: 405
Reputation: 5493
Your question isn't very clear, but it sounds like you're using docker-compose
to bring the containers up but relying on docker rm
/docker rmi
to take them down. Try doing everything with Docker Compose. Bring services up:
docker-compose up -d
Take services down but let volumes persist:
docker-compose down
Take services down and destroy volumes:
docker-compose down --volumes
https://docs.docker.com/compose/reference/down/
For the compose file you posted, you shouldn't generally need to use docker rm
/docker rmi
.
Upvotes: 4