5

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
Glasnhost
  • 591
  • 4
  • 10
  • 20

2 Answers2

5

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
Kerolos William
  • 334
  • 1
  • 13
1

try using host network if container is having issues with DNS e.g.

docker build .... --network host ....

hasnat
  • 119
  • 2
  • Not sure whether this work in docker compose as well – Sandeepa Kariyawasam Nov 25 '22 at 18:23
  • its build arg, if compose file is version 3.4. docker-compose I guess v1.x.x. https://stackoverflow.com/questions/47074457/how-to-specify-docker-build-network-host-mode-in-docker-compose-at-the-time – hasnat Apr 25 '23 at 18:01