I'm trying to work with VSCode Dev Containers, but I facing an issue.
I have a docker-compose.yml, with 2 services:
version: '3'
services:
redis:
image: redis:alpine
ports:
- "6379:6379"
worker:
depends_on:
- redis
image: app
build: .
...
But if I try to run Dev Containers: Rebuild and Reopen
, it fails to bring up the new redis container because the port 6379 is already in use: 0.0.0:6379 failed: port is already allocated
Then, to avoid this I manually run docker stop <container_id>
. But I want to automate this , or put some command inside my docker-compose.yml to prevent this, is it possible?
How can I fix this issue?
Thanks