运行添加组/添加用户。得到:Optionsisambiguous(shell,system)错误
我正在 Dockerising 我的第一个 Flask 应用程序并遵循在线指南,但在Dockerfile.prod.
RUN addgroup -S app && adduser -S app -G app
我收到错误 Option s is ambiguous (shell, system)
我遇到了这个 SO 帖子并尝试了接受的答案(几乎相同):
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
同样的结果。我试过指定--shelland --system,--group而是得到错误addgroup: Only one or two names allowed.
无论我尝试什么,我都会收到以下错误:
Option s is ambiguous (shell, system)
Option g is ambiguous (gecos, gid, group)
我在 Windows 上(使用 Docker,而不是 Docker Windows)。不确定是不是这个问题。但我找不到解决办法。
Dockerfile.prod
FROM python:3.8.1-slim-buster as builder
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install system dependencies
RUN apt-get update &&
apt-get install -y --no-install-recommends gcc
# lint
RUN pip install --upgrade pip
RUN pip install flake8
COPY . /usr/src/app/
RUN flake8 --ignore=E501,F401,E722 .
# install python dependencies
COPY ./requirements.txt .
# COPY requirements .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt
# RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements/prod.txt
# pull official base image
FROM python:3.8.1-slim-buster
# create directory for the app user
RUN mkdir -p /home/app
# create the app user
RUN addgroup -S app && adduser -S app -G app
# create the appropriate directories
ENV HOME=/home/app
ENV APP_HOME=/home/app/web
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
# install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends netcat
COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
# COPY --from=builder /usr/src/app/requirements/common.txt .
# COPY --from=builder /usr/src/app/requirements/prod.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*
# copy entrypoint-prod.sh
COPY ./entrypoint.prod.sh $APP_HOME
# copy project
COPY . $APP_HOME
# chown all the files to the app user
RUN chown -R app:app $APP_HOME
# change to the app user
USER app
# run entrypoint.prod.sh
ENTRYPOINT ["/home/app/web/entrypoint.prod.sh"]
回答
我知道您想创建一个都称为“app”的用户和组,并且用户应在该组中,两者都是系统帐户/组。
这可以通过在线使用 adduser 来实现
RUN adduser --system --group app
THE END
二维码