大网数据广告活动
服务器运维问答

RUN yum in Docker file not working, but yum it's working inside the container

· 52CE 我爱测

I'm trying to build a container from amazonlinux (fedora based). If I build the image and I enter into the container the yum command works normally. However if I put the yum command inside the Dockerfile, it doesn't. It seems tha…

问题原文

原帖链接 · Glasnhost · CC BY-SA 4.0

I'm trying to build a container from amazonlinux (fedora based).

If I build the image and I enter into the container the yum command works normally. However if I put the yum command inside the Dockerfile, it doesn't. It seems that fails to contact the repository

Dockerfile

FROM amazonlinux
RUN yum update -y

running: sudo docker build .

Sending build context to Docker daemon  3.072kB
Step 1/2 : FROM amazonlinux
---> df7d0b6ddeee
Step 2/2 : RUN yum update -y
---> Running in 14e4e4bad5b1
Loaded plugins: ovl, priorities

result, several https tried and in the end:

...URLError: (28, 'Resolving timed out after 5516 milliseconds')
Trying other mirror...
The command '/bin/sh -c yum update -y' returned a non-zero code: 1

社区高分解答

原帖链接 · Kerolos William · CC BY-SA 4.0

if I were you I would check the following things:

  • Try Centos7 image and run the same commands
  • Try to run yum clean all before running update so it should look like this RUN yum clean all && yum update -y
  • Check the network limitation in DNS resolving and you can check this link for guide and also this guide from docker to configure custom network
  • Also check the firewall configuration on the Host machine

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-01-30)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。