【发布时间】:2021-09-28 19:31:16
【问题描述】:
每次我尝试运行命令时
docker run --name django-tdd -e "PORT=8765" -p 8008:8765 registry.heroku.com/lit-sierra-68791/web:latest
我得到错误:'$' 不是有效的端口号
Dockerfile.prod
# pull official base image
FROM python:3.9.5-slim-buster
# set working directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV DEBUG 0
ENV SECRET_KEY fgerg345y4y56u5u5757jk5k56kuykykyk
ENV DJANGO_ALLOWED_HOSTS localhost 127.0.0.1 [::1]
ENV PORT 8765
# install system dependencies
RUN apt-get update \
&& apt-get -y install gcc postgresql \
&& apt-get clean
# add and install requirements
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt
# add app
COPY . .
# add and run as non-root user
RUN adduser --disabled-password myuser
USER myuser
# run gunicorn
CMD gunicorn drf_project.wsgi:application --bind 0.0.0.0:$PORT
我什至在上面的文件中添加了 ENV PORT 8765,但也没有用。
【问题讨论】:
标签: python django docker testdriven.io