在Docker Compose v3中无法用芹菜启动django

时间:2017-12-20 13:50:54

标签: docker docker-compose

这是我的docker-compose.yml:

version: '3.4'

services:
  nginx:
    restart: always
    image: nginx:latest
    ports:
      - 80:80
    volumes:
      - ./misc/nginx.conf:/etc/nginx/conf.d/default.conf
      - /static:/static
    depends_on:
      - web

  web:
    restart: always
    image: celery-with-docker-compose:latest
    build: .
    command: bash -c "python /code/manage.py collectstatic --noinput && python /code/manage.py migrate && /code/run_gunicorn.sh"
    volumes:
      - /static:/data/web/static
      - /media:/data/web/media
      - .:/code
    env_file:
      - ./.env
    depends_on:
      - db
    volumes:
      - ./app:/deploy/app

  worker:
    image: celery-with-docker-compose:latest
    restart: always
    build:
      context: .
    command: bash -c "pip install -r /code/requirements.txt && /code/run_celery.sh"
    volumes:
      - .:/code
    env_file:
      - ./.env
    depends_on:
      - redis
      - web

  db:
    restart: always
    image: postgres
    env_file:
      - ./.env
    volumes:
      - pgdata:/var/lib/postgresql/data
    ports:
      - "5432:5432"

  redis:
    restart: always
    image: redis:latest
    privileged: true
    command: bash -c "sysctl vm.overcommit_memory=1 && redis-server"
    ports:
      - "6379:6379"

volumes:
  pgdata:

当我运行docker stack deploy -c docker-compose.yml cryptex时,我得到了

Non-string key at top level: true

docker-compose -f docker-compose.yml config给了我

ERROR: In file './docker-compose.yml', the service name True must be a quoted string, i.e. 'True'.

我使用最新版本的docker和compose。我也是新手撰写v3并开始使用它来获取docker stack命令的可用性。如果您在配置文件中看到任何错误或减少,请告诉我。感谢

1 个答案:

答案 0 :(得分:0)

您必须验证docker compose文件,可能是其中的值很低

现在验证文件就像docker-compose -f一样简单 docker-compose.yml配置。与往常一样,您可以省略-f 在与docker-compose.yml部分相同的文件夹中运行时 文件本身或拥有