gpt4 book ai didi

node.js - 我怎么能在 docker ubuntu contain 上执行 'apt-get install'?

转载 作者:太空宇宙 更新时间:2023-11-03 17:12:05 25 4
gpt4 key购买 nike

首先,我使用以下命令安装并运行了 docker contain。

docker run -i -t ubuntu /bin/bash

然后我执行了以下命令。

root@d444a77039e7:/# apt-get update
0% [Connecting to archive.ubuntu.com (91.189.92.200)]

一直阻塞。

然后我运行了以下命令,但遇到了问题。

root@d444a77039e7:/# apt-get install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package nodejs

然后我像下面这样设置了 http 和 https 代理,但它也失败了。

root@d444a77039e7:/# export HTTP_PROXY=http://proxy.xxx.com
root@d444a77039e7:/# export HTTPS_PROXY=http://proxy.xxx.com

你能告诉我如何解决这个问题吗?谢谢。我的主机是redhat5.9,不支持最新版本的nodejs。所以打算安装在docker engine上。

最佳答案

这意味着您的 docker 构建尚未使用 new docker 1.9+ build-arg arguments 启动.这将避免将完整的代理(有时可以包括您的凭据)放在 Dockerfile 中:

You can use ENV instructions in a Dockerfile to define variable values. These values persist in the built image. However, often persistence is not what you want. Users want to specify variables differently depending on which host they build an image on.

A good example is http_proxy or source versions for pulling intermediate files. The ARG instruction lets Dockerfile authors define values that users can set at build-time using the --build-arg flag:

$ docker build --build-arg HTTP_PROXY=http://10.20.30.2:1234 .

This flag allows you to pass the build-time variables that are accessed like regular environment variables in the RUN instruction of the Dockerfile. Also, these values don’t persist in the intermediate or final images like ENV values do.

关于node.js - 我怎么能在 docker ubuntu contain 上执行 'apt-get install'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34302974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com