Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dockerfile编译不通过,提示错误 #1

Closed
banduoba opened this issue Sep 4, 2017 · 6 comments
Closed

dockerfile编译不通过,提示错误 #1

banduoba opened this issue Sep 4, 2017 · 6 comments

Comments

@banduoba
Copy link

banduoba commented Sep 4, 2017

dockerfile文件底37行:RUN true \ 运行到这里报错

@banduoba
Copy link
Author

banduoba commented Sep 4, 2017

Sending build context to Docker daemon  98.82kB
Step 1/10 : FROM node:6.9.1-alpine
6.9.1-alpine: Pulling from library/node
3690ec4760f9: Already exists
419f814deb4f: Pull complete
Digest: sha256:89f054ffcabab2a016a74fc6313f7be8826156157517e529c0c19d061299dd82
Status: Downloaded newer image for node:6.9.1-alpine
 ---> 3c6fe43f14ca
Step 2/10 : RUN apk add --no-cache   make gcc g++ python   ca-certificates tzdata   zsh curl wget vim git
 ---> Running in 83b3b524a7f6
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz: temporary error (try again later)
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz: temporary error (try again later)
ERROR: unsatisfiable constraints:
  ca-certificates (missing):
    required by: world[ca-certificates]
  curl (missing):
    required by: world[curl]
  g++ (missing):
    required by: world[g++]
  gcc (missing):
    required by: world[gcc]
  git (missing):
    required by: world[git]
  make (missing):
    required by: world[make]
  python (missing):
    required by: world[python]
  tzdata (missing):
    required by: world[tzdata]
  vim (missing):
    required by: world[vim]
  wget (missing):
    required by: world[wget]
  zsh (missing):
    required by: world[zsh]
The command '/bin/sh -c apk add --no-cache   make gcc g++ python   ca-certificates tzdata   zsh curl wget vim git' returned a non-zero code: 11

@springjk
Copy link
Owner

springjk commented Sep 4, 2017

刚才编译了一次测试是 OK 的,运行时如下:

 springjk@springjk-PC  ~/Project  git clone https://github.com/springjk/web-dev-docker.git
正克隆到 'web-dev-docker'...
remote: Counting objects: 25, done.
remote: Total 25 (delta 0), reused 0 (delta 0), pack-reused 25
展开对象中: 100% (25/25), 完成.
 springjk@springjk-PC  ~/Project  cd web-dev-docker 
sudo docker build -t webdev .            
Sending build context to Docker daemon 99.33 kB
Step 1/10 : FROM node:6.9.1-alpine
 ---> 3c6fe43f14ca
Step 2/10 : RUN apk add --no-cache   make gcc g++ python   ca-certificates tzdata   zsh curl wget vim git
 ---> Running in 81b3a842c2e5
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
(1/38) Upgrading musl (1.1.14-r14 -> 1.1.14-r15)
(2/38) Installing ca-certificates (20161130-r0)
(3/38) Installing libssh2 (1.7.0-r0)
(4/38) Installing libcurl (7.55.0-r0)
(5/38) Installing curl (7.55.0-r0)
(6/38) Installing binutils-libs (2.26-r1)
(7/38) Installing binutils (2.26-r1)
(8/38) Installing gmp (6.1.0-r0)
(9/38) Installing isl (0.14.1-r0)
(10/38) Installing libgomp (5.3.0-r0)
(11/38) Installing libatomic (5.3.0-r0)
(12/38) Installing pkgconf (0.9.12-r0)
(13/38) Installing pkgconfig (0.25-r1)
(14/38) Installing mpfr3 (3.1.2-r0)
(15/38) Installing mpc1 (1.0.3-r0)
(16/38) Installing gcc (5.3.0-r0)
(17/38) Installing musl-dev (1.1.14-r15)
(18/38) Installing libc-dev (0.7-r0)
(19/38) Installing g++ (5.3.0-r0)
(20/38) Installing expat (2.2.0-r1)
(21/38) Installing pcre (8.38-r1)
(22/38) Installing git (2.8.6-r0)
(23/38) Upgrading musl-utils (1.1.14-r14 -> 1.1.14-r15)
(24/38) Installing make (4.1-r1)
(25/38) Installing libbz2 (1.0.6-r5)
(26/38) Installing libffi (3.2.1-r2)
(27/38) Installing gdbm (1.11-r1)
(28/38) Installing ncurses-terminfo-base (6.0-r8)
(29/38) Installing ncurses-terminfo (6.0-r8)
(30/38) Installing ncurses-libs (6.0-r8)
(31/38) Installing readline (6.3.008-r4)
(32/38) Installing sqlite-libs (3.13.0-r0)
(33/38) Installing python (2.7.12-r0)
(34/38) Installing tzdata (2016d-r0)
(35/38) Installing lua5.2-libs (5.2.4-r2)
(36/38) Installing vim (7.4.1831-r3)
(37/38) Installing wget (1.18-r1)
(38/38) Installing zsh (5.2-r1)
Executing zsh-5.2-r1.post-install
Executing busybox-1.24.2-r11.trigger
Executing ca-certificates-20161130-r0.trigger
OK: 257 MiB in 49 packages
 ---> 5348f03179dd
Removing intermediate container 81b3a842c2e5
Step 3/10 : RUN npm install -g   cnpm   yarn   webpack   bower   browserify   gulp   grunt   babel   less   node-sass   coffee-script   vue-cli   webpack-dev-server   anywhere
 ---> Running in b07ba67aa040
npm info it worked if it ends with ok
npm 信息省略……
Step 6/10 : EXPOSE 80 8080
 ---> Running in f2c2768e8bdd
 ---> 91ed4cdd73c9
Removing intermediate container f2c2768e8bdd
Step 7/10 : RUN mkdir /workspace
 ---> Running in 8fc81af7cb71
 ---> 79b479275064
Removing intermediate container 8fc81af7cb71
Step 8/10 : WORKDIR /workspace
 ---> 2866103372cc
Removing intermediate container 14d4c2224a29
Step 9/10 : VOLUME /workspace
 ---> Running in 621ed02c5870
 ---> 19d78c795c8a
Removing intermediate container 621ed02c5870
Step 10/10 : CMD zsh
 ---> Running in 88b6b95aec3c
 ---> ec4a0bb99ab8
Removing intermediate container 88b6b95aec3c
Successfully built ec4a0bb99ab8

你的问题应该是网络问题,你在使用时对终端进行了代理吗?alpine 的包可能被墙了的,在终端尝试访问 curl http://dl-4.alpinelinux.org/alpine/, 理论结果为:

➜   curl http://dl-4.alpinelinux.org/alpine/
<html>
<head><title>Index of /alpine/</title></head>
<body bgcolor="white">
<h1>Index of /alpine/</h1><hr><pre><a href="../">../</a>
<a href="edge/">edge/</a>                                              30-Sep-2015 07:58                   -
<a href="latest-stable/">latest-stable/</a>                                     20-Apr-2017 10:47                   -
<a href="v2.4/">v2.4/</a>                                              19-Dec-2012 15:22                   -
<a href="v2.5/">v2.5/</a>                                              31-Oct-2012 12:46                   -
<a href="v2.6/">v2.6/</a>                                              09-Oct-2013 13:50                   -
<a href="v2.7/">v2.7/</a>                                              12-Mar-2014 12:55                   -
<a href="v3.0/">v3.0/</a>                                              07-May-2014 22:52                   -
<a href="v3.1/">v3.1/</a>                                              01-Jan-2015 07:25                   -
<a href="v3.2/">v3.2/</a>                                              24-Apr-2015 09:24                   -
<a href="v3.3/">v3.3/</a>                                              21-Dec-2015 14:43                   -
<a href="v3.4/">v3.4/</a>                                              21-Apr-2016 12:39                   -
<a href="v3.5/">v3.5/</a>                                              16-Nov-2016 16:01                   -
<a href="v3.6/">v3.6/</a>                                              20-Apr-2017 10:47                   -
<a href="MIRRORS.txt">MIRRORS.txt</a>                                        24-Apr-2017 21:53                 793
</pre><hr></body>
</html>

尝试全局翻墙后重试,确保你的网路国际出口正常。

@banduoba
Copy link
Author

banduoba commented Sep 8, 2017

@springjk 刚刚试了一下 还是这样错误
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz: temporary error (try again later) fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz: temporary error (try again later) ERROR: unsatisfiable constraints: ca-certificates (missing): required by: world[ca-certificates] curl (missing):

我curl http://dl-4.alpinelinux.org/alpine/这个和你显示的一样,也开启了全局代理,另外我curl http://dl-cdn.alpinelinux.org/alpine/ 也是没有问题的

@banduoba
Copy link
Author

banduoba commented Sep 8, 2017

另外mac下 docker那个工具是不是要设置代理

@banduoba
Copy link
Author

banduoba commented Sep 9, 2017

现在好了,可以创建了,就是遇到另一个问题,docker build过程很缓慢,尤其是到了(16/38) Installing gcc (5.3.0-r0)这一步骤,可能是和网络有关系,请问这个可以在dockerfile怎么更改为国内的源么

@springjk
Copy link
Owner

你这里确实是网络问题,解决这个的最好办法是翻墙而不是设置国内源,国内的源因为使用人数非常多以及都是一些学校来做业余维护,非常不稳定,存在更新滞后、间歇性不可用以及服务中断等问题……言归正传,解决这个问题的方法是:

  1. 使用云编译,如 daocloud docker-hub 等,云编译本身就在墙外或自带梯子,不会存在网络问题
  2. 本地进行全局代理,传统的 Socket HTTPS 等代理并非全局代理,大多只能代理到浏览器,建议使用工具设置为全局代理或直接使用 VPN 代理方式
  3. 设置国内源, 这也是最麻烦的一种,首先你要找一个好的源,如果阿里有提供最好,此处你应该是在安装包的时候出了问题,需要使用 alpine 的国内源,你可以在 Dockerfile 中进行添加对应的命令,不同的操作系统可能会有差异,可参考此处

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants