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

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

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 &quot;unsafe-perm=true&quot; &gt; .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 [&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:

确定