0
votes

I have tried to build the below Dockerfile, for the first time it built successfully but after that it is throwing the mentioned error. I am mentioning the Dockerfile and error below.

Dockerfile:

FROM alpine

RUN apk add --update redis

CMD ["redis-server"]

Error:

Sending build context to Docker daemon 2.048kB Step 1/3 : FROM alpine ---> e7d92cdc71fe Step 2/3 : RUN apk add --update redis ---> Running in c03f589ce9da fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.11/main: temporary error (try again later) WARNING: Ignoring APKINDEX.70f61090.tar.gz: No such file or directory fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.11/community: temporary error (try again later) WARNING: Ignoring APKINDEX.ca2fea5b.tar.gz: No such file or directory ERROR: unsatisfiable constraints: redis (missing): required by: world[redis] The command '/bin/sh -c apk add --update redis' returned a non-zero code: 1

2
Have you tried to retry later as the error suggests (temporary error (try again later)) ? Have you checked that you can successfully connect to the Internet, especially to dl-cdn.alpinelinux.org/alpine/v3.11/main ? By the way, there are official Redis images already available (for example redis:5.0.7-alpine), there should be no need to rebuild one. - norbjd
@norbjd I retried after while but that didn't work out, also I have working internet connection. The links are also working fine. I also tried to build the below Dockerfile : FROM node:current-slim WORKDIR /usr/src/app COPY package.json . RUN npm install EXPOSE 8080 CMD [ "npm", "start" ] COPY . . But the error is : npm ERR! request to registry.npmjs.org/bootstrap failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2020-02-18T11_01_49_170Z-debug.log I am new to docker. - Sarang G
It looks like you cannot connect to the Internet from the container. Could you try 1) to ping something on the Internet from a container : docker run --rm -it alpine:3.11 ping alpinelinux.org and 2) run ping from Dockerfile (just add RUN ping alpinelinux.org). If this does not work, could you also try to ping the IP instead of the domain name and see what happen? - norbjd
@norbjd i also think that i cant connect to internet from container, I ran first command and the result was ping: bad address 'alpinelinux.org' and for 2nd command the result was Sending build context to Docker daemon 2.048kB Step 1/2 : FROM ubuntu ---> ccc6e87d482b Step 2/2 : RUN ping alpinelinux.org ---> Running in f94af01d102a /bin/sh: 1: ping: not found I am also unable to run docker run busybox ping google.com - Sarang G
Could you ping directly the IP from the container (you can get the IP by running ping alpinelinux.org from your host for example)? - norbjd

2 Answers

0
votes

Create a file daemon.json in the location: /etc/docker/daemon.json

{
    "dns": ["8.8.8.8"]
}

Then restart docker: systemctl restart docker

-1
votes

Kindly check http://dl-cdn.alpinelinux.org/alpine/v3.11 in your browser, if you are able to access then you can access through your docker container as well.