简体   繁体   中英

Docker compose: command after docker-compose run command

I follow this tutorial: Python Docker compose In this tutorial, it will create a docker compose file:

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

After that, running docker compose command for building project:

docker-compose run web django-admin.py startproject composeexample .

The thing I don't know is: as I read another docker tutorial, often we just run docker-compose run for running project. What is the meaning of those commands after: web django-admin.py startproject composeexample . As I understand, this command means: creating a python project first, and then calling docker-compose.yml for configuration. Right?

docker-compose run is used to run a one-time command in a service's container. It cannot be used without arguments - at least service name is required. For more information on that command please refer to the documentation . The command you mentioned:

docker-compose run web django-admin.py startproject composeexample .

executes django-admin.py startproject composeexample . in the web container of your project, overriding the default command

command: python manage.py runserver 0.0.0.0:8000

specified for the web service in docker-compose.yml.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM