创建Docker映像时出现互联网连接问题

时间:2020-09-27 14:57:14

标签: node.js docker

我正在尝试在AWS EC2中创建一个简单的docker映像。

我有以下Dockerfile。

FROM node:12-alpine

RUN apk add --no-cache build-base gcc autoconf automake libtool zlib-dev libpng-dev nasm

RUN mkdir -p /home/project/website/node_modules && chown -R node:node /home/project/website

WORKDIR /home/project/website

COPY /package*.json ./

USER node

RUN npm cache verify

RUN npm install

COPY --chown=node:node . .

RUN chmod +x wait-for.sh

RUN chmod -R 0755 /home/project/website/src/views/

EXPOSE 8000

当我尝试通过以下命令进行构建时 docker-compose build

我得到以下输出

Step 2/12 : RUN apk add --no-cache build-base gcc autoconf automake libtool zlib-dev libpng-dev nasm
 ---> Running in 208f43729d68
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz: network error (check Internet connection and firewall)
  autoconf (missing):
    required by: world[autoconf]
  automake (missing):
    required by: world[automake]
  build-base (missing):
    required by: world[build-base]
  gcc (missing):
    required by: world[gcc]
  libpng-dev (missing):
    required by: world[libpng-dev]
  libtool (missing):
    required by: world[libtool]
  nasm (missing):
    required by: world[nasm]
  zlib-dev (missing):
    required by: world[zlib-dev]
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz: network error (check Internet connection and firewall)
ERROR: unsatisfiable constraints:

并且我已经是第一次创建它,并且一切都运行成功,但是我更改了docker文件上的某些路径,并且删除了所有容器,图像,卷... 但是这次我遇到了这个错误。

1 个答案:

答案 0 :(得分:0)

我通过以下命令解决了这个问题

pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
docker -d

这是原始答案

My docker container has no internet