How can I implement the below docker-compose
code, but using the docker run
command? I am specifically interested in the depends_on
part.
version: '2'
services:
db:
image: postgres
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
2
Answers
depends_on:
doesn’t map to adocker run
option. When you have your twodocker run
commands you need to make sure you put them in the right order.depends-on mean :
Compose implementations MUST guarantee dependency services have been started before starting a dependent service. Compose implementations MAY wait for dependency services to be “ready” before starting a dependent service.
Hence the depends on is not only an order of running
and you can use docker-compose instead of docker run and every option in docker run can be in the docker-compose file