Reputation: 3151
Hi I am trying build a docker and Docker file looks like this.
FROM alpine
LABEL description "Nginx + uWSGI + Flask based on Alpine Linux and managed by Supervisord"
# Copy python requirements file
COPY requirements.txt /tmp/requirements.txt
RUN apk add --no-cache \
python3 \
bash \
nginx \
uwsgi \
uwsgi-python3 \
supervisor && \
python3 -m ensurepip && \
rm -r /usr/lib/python*/ensurepip && \
pip3 install --upgrade pip setuptools && \
pip3 install -r /tmp/requirements.txt && \
rm /etc/nginx/conf.d/default.conf && \
rm -r /root/.cache
# Copy the Nginx global conf
COPY nginx.conf /etc/nginx/
# Copy the Flask Nginx site conf
COPY flask-site-nginx.conf /etc/nginx/conf.d/
# Copy the base uWSGI ini file to enable default dynamic uwsgi process number
COPY uwsgi.ini /etc/uwsgi/
# Custom Supervisord config
COPY supervisord.conf /etc/supervisord.conf
# Add demo app
COPY ./app /app
WORKDIR /app
CMD ["/usr/bin/supervisord"]
Errors looks like
Sending build context to Docker daemon 250.9kB
Step 1/11 : FROM alpine
---> 196d12cf6ab1
Step 2/11 : LABEL description "Nginx + uWSGI + Flask based on Alpine Linux and managed by Supervisord"
---> Using cache
---> d8d38c761b8d
Step 3/11 : COPY requirements.txt /tmp/requirements.txt
---> Using cache
---> cb29eb34ca46
Step 4/11 : RUN apk add --no-cache python3 bash nginx uwsgi uwsgi-python3 supervisor && python3 -m ensurepip && rm -r /usr/lib/python*/ensurepip && pip3 install --upgrade pip setuptools && pip3 install -r /tmp/requirements.txt && rm /etc/nginx/conf.d/default.conf && rm -r /root/.cache
---> Running in 3d568d2620dd
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz: could not connect to server (check repositories file)
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz: could not connect to server (check repositories file)
ERROR: unsatisfiable constraints:
bash (missing):
required by: world[bash]
nginx (missing):
required by: world[nginx]
python3 (missing):
required by: world[python3]
supervisor (missing):
required by: world[supervisor]
uwsgi (missing):
required by: world[uwsgi]
uwsgi-python3 (missing):
required by: world[uwsgi-python3]
The command '/bin/sh -c apk add --no-cache python3 bash nginx uwsgi uwsgi-python3 supervisor && python3 -m ensurepip && rm -r /usr/lib/python*/ensurepip && pip3 install --upgrade pip setuptools && pip3 install -r /tmp/requirements.txt && rm /etc/nginx/conf.d/default.conf && rm -r /root/.cache' returned a non-zero code: 6
A month ago it was building fine. Because of the limited knowledge in Docker i couldn't to figure what's causing the error. A quick google search has resulted in these two links: link1 link2 But none of them were working.
Upvotes: 63
Views: 124703
Reputation: 1349
In my case I had changed the /etc/docker/daemon.json and added a repository-mirrors to bypass filtering in my region and download docker images from that repo.
daemon.json:
{
"registry-mirrors": [
"https://docker.somerepo.com"
],
"insecure-registries": [],
"debug": true,
"experimental": false
}
so that was the problem, I removed daemon.json file (or you could comment all lines in the daemon.json file) and it was fine to go and download new docker images.
Upvotes: 0
Reputation: 632
Using Google (8.8.8.8
) or Cloudflare (1.1.1.1
) DNS will suffice for most of the users.
But for Iranian(or any other region where docker is prohibited there) users, due to the sanctions, there are limits when using docker, so you may also change the registry-mirrors
to a local (Iranian) mirror.
daemon.json:
{
"dns": ["8.8.8.8"],
"registry-mirrors": ["https://registry.docker.ir"]
}
Another option for people in Iran is to use Shecan DNS.
daemon.json:
{
"dns": ["185.51.200.2"],
}
Don't forget to restart the docker service after editing the config file.
1. Linux: sudo systemctl restart docker docker.service
2. Windows: check out here for further instructions
File Location:
1. Linux: /etc/docker/daemon.json
2. Windows: C:/Users/{'USERNAME'})/.docker/daemon.json
Upvotes: 5
Reputation: 357
I came across same issue you might want to disable internet security or any VPN if you are connected with it.
Upvotes: -2
Reputation: 2294
I still ran into this problem as of dez 2022 with debian buster. Docker on Buster seems to be incompOption 2 here solved the problem for me.
Upvotes: 0
Reputation: 1211
-In Ubuntu
It was a DNS error for me. By setting /etc/docker/daemon.json with,
{
"dns": ["8.8.8.8"]
}
and then restarting docker with,
sudo service docker restart
I was able to build images again.
https://github.com/gliderlabs/docker-alpine/issues/334#issuecomment-450598069
-In Windows
C:/Users/Administrator(or any other Username)/.docker/daemon.json
And add
{
...,
"dns": ["8.8.8.8"]
}
Upvotes: 35
Reputation: 6548
Try restarting the docker service, it worked for me and others:
sudo systemctl restart docker docker.service
Thanks to: https://github.com/gliderlabs/docker-alpine/issues/334#issuecomment-408826204
Upvotes: 16
Reputation: 129
This kind of errors often happend due to some network problem.
Try use https mirrors instead of http.
RUN sed -i -e 's/http:/https:/' /etc/apk/repositories
Upvotes: 8
Reputation: 433
Another fix -
I added 8.8.8.8
to my /etc/resolv.conf
and restarted the docker daemon. It fixed this issue for me.
Upvotes: 3
Reputation: 13295
Providing a more generic troubleshooting answer for the title. Test your docker commands in another container. This could be another running container that you don't mind breaking, or preferably a base container (in this case alpine) where you can run the Dockerfile commands on the shell. Probably not a solution where the network is the issue as in the original question, but good in other cases.
The apk error messages aren't always the most useful. Take a look at the example below:
/ # apk add --no-cache influxdb-client
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
influxdb-client (missing):
required by: world[influxdb-client]
/ #
/ #
/ #
/ #
/ # apk add --no-cache influxdb
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/1) Installing influxdb (1.8.0-r1)
Executing influxdb-1.8.0-r1.pre-install
Executing busybox-1.31.1-r19.trigger
OK: 613 MiB in 98 packages
By the way, https://pkgs.alpinelinux.org/packages is a good place to find the names of packages for Alpine, which would fix the above example.
Upvotes: 2
Reputation: 21
If you are able to manually download the file, try restarting your docker service. It did the trick for me..
Upvotes: 2
Reputation: 8153
The line:
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz: could not connect to server (check repositories file)
Basically says that you are either offline, or the alpinelinux repo is down. I cannot find anything about it on the internet, but it happened several times in the past. Or it can be network problem somewhere in between you and the cdn.
You can always pick mirror yourself from the http://dl-cdn.alpinelinux.org/alpine/MIRRORS.txt and setup it like so:
RUN echo http://repository.fit.cvut.cz/mirrors/alpine/v3.8/main > /etc/apk/repositories; \
echo http://repository.fit.cvut.cz/mirrors/alpine/v3.8/community >> /etc/apk/repositories
(change the v3.8
according to you version)
Also as @emix pointed out, you should never use :latest
tag for your base image. Use for example 3.8
, or the one with packages versions you need.
Upvotes: 12
Reputation: 3151
Build docker with flag "--network host" solved the issue. Here is the link.
Upvotes: 118