英文:
Docker - Error: dockerfile parse error on line 3: unknown instruction: export
问题
Error: dockerfile parse error on line 3: unknown instruction: export (did you mean expose?)
错误:在第3行的Dockerfile中发生dockerfile解析错误:未知指令:export(您是不是想要写成expose?)
The Dockerfile looks like this:
Dockerfile如下:
### 构建器(用于前端) ###
export DOCKER_BUILDKIT=1
docker build -t myimage .
FROM node:19.3-buster-slim
# Switch to the node_modules install directory (if -g is used)
# So NODE_MODULES env var is set correctly
# 切换到node_modules安装目录(如果使用-g选项)
# 以确保NODE_MODULES环境变量被正确设置
WORKDIR /usr/local/lib/node_modules
COPY frontend/node-requirements.txt ./node-requirements.txt
RUN echo "unsafe-perm=true" > .npmrc
RUN cat node-requirements.txt | xargs npm install -g
COPY --chmod=0755 .docker/builder/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY frontend /app
VOLUME /app
ENTRYPOINT ["entrypoint.sh"]```
Does anyone have any idea on what could be causing this error? Any help would be greatly appreciated. Thank you in advance!
有人知道是什么原因导致了这个错误吗?任何帮助将不胜感激。提前谢谢!
<details>
<summary>英文:</summary>
Okay, after a complete new install of Docker. I am getting an error when trying to do sudo docker-compose build on a Dockerfile.
Error: dockerfile parse error on line 3: unknown instruction: export (did you mean expose?)
docker-compose build on the Dockerfile. The error is
dockerfile parse error on line 3: unknown instruction: export (did you mean expose?)
ERROR: Service 'builder' failed to build : Build failed
The Dockerfile looks like this:
Builder (for Frontend)
export DOCKER_BUILDKIT=1
docker build -t myimage .
FROM node:19.3-buster-slim
Switch to the node_modules install directory (if -g is used)
So NODE_MODULES env var is set correctly
WORKDIR /usr/local/lib/node_modules
COPY frontend/node-requirements.txt ./node-requirements.txt
RUN echo "unsafe-perm=true" > .npmrc
RUN cat node-requirements.txt | xargs npm install -g
COPY --chmod=0755 .docker/builder/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY frontend /app
VOLUME /app
ENTRYPOINT ["entrypoint.sh"]
Does anyone have any idea on what could be causing this error? Any help would be greatly appreciated. Thank you in advance!
</details>
# 答案1
**得分**: 1
以下是翻译好的部分:
Commands to run in terminal:
```bash
$ export DOCKER_BUILDKIT=1
$ docker build -t myimage .
Dockerfile Content:
FROM node:19.3-buster-slim
# Switch to the node_modules install directory (if -g is used)
# So NODE_MODULES env var is set correctly
WORKDIR /usr/local/lib/node_modules
COPY frontend/node-requirements.txt ./node-requirements.txt
RUN echo "unsafe-perm=true" > .npmrc
RUN cat node-requirements.txt | xargs npm install -g
COPY --chmod=0755 .docker/builder/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY frontend /app
VOLUME /app
ENTRYPOINT ["entrypoint.sh"]
英文:
First two commands are bash commands, not part of Dockerfile.
Commands to run in terminal:
$ export DOCKER_BUILDKIT=1
$ docker build -t myimage .
Dockerfile Content:
FROM node:19.3-buster-slim
# Switch to the node_modules install directory (if -g is used)
# So NODE_MODULES env var is set correctly
WORKDIR /usr/local/lib/node_modules
COPY frontend/node-requirements.txt ./node-requirements.txt
RUN echo "unsafe-perm=true" > .npmrc
RUN cat node-requirements.txt | xargs npm install -g
COPY --chmod=0755 .docker/builder/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY frontend /app
VOLUME /app
ENTRYPOINT ["entrypoint.sh"]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论