Docker – 错误:dockerfile 在第3行解析时出错:未知指令:export

huangapple go评论99阅读模式
英文:

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如下:

  1. ### 构建器(用于前端) ###
  2. export DOCKER_BUILDKIT=1
  3. docker build -t myimage .
  4. FROM node:19.3-buster-slim
  5. # Switch to the node_modules install directory (if -g is used)
  6. # So NODE_MODULES env var is set correctly
  7. # 切换到node_modules安装目录(如果使用-g选项)
  8. # 以确保NODE_MODULES环境变量被正确设置
  9. WORKDIR /usr/local/lib/node_modules
  10. COPY frontend/node-requirements.txt ./node-requirements.txt
  11. RUN echo "unsafe-perm=true" > .npmrc
  12. RUN cat node-requirements.txt | xargs npm install -g
  13. COPY --chmod=0755 .docker/builder/entrypoint.sh /usr/local/bin/entrypoint.sh
  14. COPY frontend /app
  15. VOLUME /app
  16. ENTRYPOINT ["entrypoint.sh"]```
  17. Does anyone have any idea on what could be causing this error? Any help would be greatly appreciated. Thank you in advance!
  18. 有人知道是什么原因导致了这个错误吗?任何帮助将不胜感激。提前谢谢!
  19. <details>
  20. <summary>英文:</summary>
  21. Okay, after a complete new install of Docker. I am getting an error when trying to do sudo docker-compose build on a Dockerfile.
  22. 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

  1. 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"]

  1. Does anyone have any idea on what could be causing this error? Any help would be greatly appreciated. Thank you in advance!
  2. </details>
  3. # 答案1
  4. **得分**: 1
  5. 以下是翻译好的部分:
  6. Commands to run in terminal:
  7. ```bash
  8. $ export DOCKER_BUILDKIT=1
  9. $ docker build -t myimage .

Dockerfile Content:

  1. FROM node:19.3-buster-slim
  2. # Switch to the node_modules install directory (if -g is used)
  3. # So NODE_MODULES env var is set correctly
  4. WORKDIR /usr/local/lib/node_modules
  5. COPY frontend/node-requirements.txt ./node-requirements.txt
  6. RUN echo "unsafe-perm=true" > .npmrc
  7. RUN cat node-requirements.txt | xargs npm install -g
  8. COPY --chmod=0755 .docker/builder/entrypoint.sh /usr/local/bin/entrypoint.sh
  9. COPY frontend /app
  10. VOLUME /app
  11. ENTRYPOINT ["entrypoint.sh"]
英文:

First two commands are bash commands, not part of Dockerfile.

Commands to run in terminal:

  1. $ export DOCKER_BUILDKIT=1
  2. $ docker build -t myimage .

Dockerfile Content:

  1. FROM node:19.3-buster-slim
  2. # Switch to the node_modules install directory (if -g is used)
  3. # So NODE_MODULES env var is set correctly
  4. WORKDIR /usr/local/lib/node_modules
  5. COPY frontend/node-requirements.txt ./node-requirements.txt
  6. RUN echo &quot;unsafe-perm=true&quot; &gt; .npmrc
  7. RUN cat node-requirements.txt | xargs npm install -g
  8. COPY --chmod=0755 .docker/builder/entrypoint.sh /usr/local/bin/entrypoint.sh
  9. COPY frontend /app
  10. VOLUME /app
  11. ENTRYPOINT [&quot;entrypoint.sh&quot;]

huangapple
  • 本文由 发表于 2023年3月7日 05:35:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75656058.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定