Dockerfile parse错误第18行:ARG名称不能为空白
这是Dockerfile,我在第18行中遇到错误 我创建了一个要求。dev.txt文件,因此这些依赖项不应在生产中执行,而应仅对开发执行。
我在.yml文件中将该文件覆盖为true。
Dockerfile:
# Install Python 3.9 image
FROM python:3.9-alpine3.13
# maintainer of the image
LABEL maintainer="tenz8"
# for faster response
ENV PYTHONBUFFERED 1
COPY ./requirements.txt /tmp/requirements.txt
COPY ./requirements.dev.txt /tmp/requirements.dev.txt
COPY ./app /app
WORKDIR /app
EXPOSE 8000
#getting overrided in decker-compose.yml
ARG DEV = false
# &&/ used to create new lines for lighter dockerfile
RUN python -m venv /py && \
/py/bin/pip install --upgrade pip && \
/py/bin/pip install -r /tmp/requirements.txt && \
#if condition in shell scripting
if [ $DEV = "true" ]; \
then /py/bin/pip install -r /tmp/requirements.dev.txt ; \
# fi means end of if condition
fi && \
rm -rf /tmp && \
adduser \
--disabled-password \
--no-create-home \
django-user
ENV PATH="/py/bin:$PATH"
USER django-user
docker-compose.yml:
version: "3.9"
services:
app:
build:
context: .
args:
- DEV=true
ports:
- "8000:8000"
volumes:
- ./app:/app
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
This is the Dockerfile, I am getting error at Line 18 i.e. ARG DEV =false,
I created a requirements.dev.txt file so those dependencies should not execute on the production but only on the development.
I am overridding that file as true in a .yml file.
Dockerfile:
# Install Python 3.9 image
FROM python:3.9-alpine3.13
# maintainer of the image
LABEL maintainer="tenz8"
# for faster response
ENV PYTHONBUFFERED 1
COPY ./requirements.txt /tmp/requirements.txt
COPY ./requirements.dev.txt /tmp/requirements.dev.txt
COPY ./app /app
WORKDIR /app
EXPOSE 8000
#getting overrided in decker-compose.yml
ARG DEV = false
# &&/ used to create new lines for lighter dockerfile
RUN python -m venv /py && \
/py/bin/pip install --upgrade pip && \
/py/bin/pip install -r /tmp/requirements.txt && \
#if condition in shell scripting
if [ $DEV = "true" ]; \
then /py/bin/pip install -r /tmp/requirements.dev.txt ; \
# fi means end of if condition
fi && \
rm -rf /tmp && \
adduser \
--disabled-password \
--no-create-home \
django-user
ENV PATH="/py/bin:$PATH"
USER django-user
docker-compose.yml:
version: "3.9"
services:
app:
build:
context: .
args:
- DEV=true
ports:
- "8000:8000"
volumes:
- ./app:/app
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
分配值时不应该有任何空间。
只需删除空间。
Arguments should not have any space while assigning the value.
Just remove the space.