繁体   English   中英

创建 docker 映像时出错:“/bin/sh: 1: -E: not found”

[英]Error creating docker image: "/bin/sh: 1: -E: not found"

我尝试从 Dockerfile 构建映像,但收到此错误:

/bin/sh: 1: -E: not found
The command '/bin/sh -c curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | -E bash -' returned a non-zero code: 127.

我得到它是因为 Dockerfile 中的以下行:

RUN  install curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | -E bash -

我尝试从 Dockerfile 构建映像,但收到此错误:

/bin/sh: 1: -E: not found
The command '/bin/sh -c curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | -E bash -' returned a non-zero code: 127.

如您在 Dockerfile RUN 以及上述错误中所见

RUN  install curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | -E bash -

-E bash -没有sudo没有意义

请更正为

RUN  curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash -

由于在 Dockerfile 中没有指定USER <user> ,因此在构建期间默认用户将是 root,因为您的父映像是 ubuntu。

请注意 Dockerfile 中的默认用户是父映像的用户,在您的情况下,它的ubuntu:latest ( FROM ubuntu:latest AS deploy ) 默认情况下,可以有非 root 的图像。

如果您在非 docker 环境中安装,您可以使用curl -sL.... | sudo -E bash - curl -sL.... | sudo -E bash -

$ man sudo
   .....
-E, --preserve-env
    Indicates to the security policy that the user wishes to preserve their existing 
    environment variables. The security policy may return 
    an error if the user does not have permission to preserve the environment.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM