使用env变量时Docker撰写错误

时间:2020-09-23 14:16:46

标签: docker docker-compose

所以我有.env文件,该文件将用于docker compose文件

FLASK_APP=bin/run.py
FLASK_ENV=production
APP_PORT=8000

docker-compose.yml

version: '3.7'

services:
  web:
    build:
      context: ./
      dockerfile: Dockerfile
    command: gunicorn --bind 0.0.0.0:${APP_PORT} --worker-class eventlet --workers 1 --worker-connections 2000 --timeout 6000 bin.run:flask_app
    ports:
      - "${APP_PORT}:${APP_PORT}"
    env_file:
      - ./.env.prod

我正在使用bash脚本运行docker-compose:

#!/bin/sh
export $(xargs < .env.prod)
docker-compose -f docker-compose.yml up -d --build

docker是成功构建,但是当我尝试使用docker-compose logsdocker-compose ps登录或ps时,出现错误:

ERROR: The Compose file './docker-compose.yml' is invalid because:
services.web.ports contains an invalid type, it should be a number, or an object

0 个答案:

没有答案