简体   繁体   English

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

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

I try to build image from Dockerfile, but I receive this error:我尝试从 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.

I get it because of the following line in the Dockerfile:我得到它是因为 Dockerfile 中的以下行:

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

I try to build image from Dockerfile, but I receive this error:我尝试从 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.

As you can see in Dockerfile RUN as well as in above error如您在 Dockerfile RUN 以及上述错误中所见

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

-E bash - has no meaning without sudo -E bash -没有sudo没有意义

Please correct to请更正为

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

Since nowhere USER <user> is specified in your Dockerfile, during build default user will be root as your parent image is ubuntu.由于在 Dockerfile 中没有指定USER <user> ,因此在构建期间默认用户将是 root,因为您的父映像是 ubuntu。

Please note the default user in a Dockerfile is the user of the parent image, in your case its ubuntu:latest ( FROM ubuntu:latest AS deploy ).请注意 Dockerfile 中的默认用户是父映像的用户,在您的情况下,它的ubuntu:latest ( FROM ubuntu:latest AS deploy ) There can be images which are non-root by default.默认情况下,可以有非 root 的图像。

If you're installing on non-docker environment you can use curl -sL.... | sudo -E bash -如果您在非 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