FROM centos:7
MAINTAINER zhangsan zs@163.com
LABEL version="1.0" description="this is a custom centos image"
ENV WORKPATH /usr/local
WORKDIR $WORKPATH
RUN yum -y install vim net-tools wget
CMD /bin/bash
docker build -t cento7:1.0 . #执行以上docker file报错
[+] Building 28.9s (6/6) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 302B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/centos:7 0.0s
=> CACHED [1/3] FROM docker.io/library/centos:7 0.0s
=> [2/3] WORKDIR /usr/local 3.8s
=> ERROR [3/3] RUN yum -y install vim net-tools wget 24.9s
------
> [3/3] RUN yum -y install vim net-tools wget:
#0 4.173 Loaded plugins: fastestmirror, ovl
#0 4.304 Determining fastest mirrors
#0 24.84 Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was
#0 24.84 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
#0 24.86
#0 24.86
#0 24.86 One of the configured repositories failed (Unknown),
#0 24.86 and yum doesn't have enough cached data to continue. At this point the only
#0 24.86 safe thing yum can do is fail. There are a few ways to work "fix" this:
#0 24.86
#0 24.86 1. Contact the upstream for the repository and get them to fix the problem.
#0 24.86
#0 24.86 2. Reconfigure the baseurl/etc. for the repository, to point to a working
#0 24.86 upstream. This is most often useful if you are using a newer
#0 24.86 distribution release than is supported by the repository (and the
#0 24.86 packages for the previous distribution release still work).
#0 24.86
#0 24.86 3. Run the command with the repository temporarily disabled
#0 24.86 yum --disablerepo=<repoid> ...
#0 24.86
#0 24.86 4. Disable the repository permanently, so yum won't use it by default. Yum
#0 24.86 will then just ignore the repository until you permanently enable it
#0 24.86 again or use --enablerepo for temporary usage:
#0 24.86
#0 24.86 yum-config-manager --disable <repoid>
#0 24.86 or
#0 24.86 subscription-manager repos --disable=<repoid>
#0 24.86
#0 24.86 5. Configure the failing repository to be skipped, if it is unavailable.
#0 24.86 Note that yum will try to contact the repo. when it runs most commands,
#0 24.86 so will have to try and fail each time (and thus. yum will be be much
#0 24.86 slower). If it is a very temporary problem though, this is often a nice
#0 24.86 compromise:
#0 24.86
#0 24.86 yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
#0 24.86
#0 24.86 Cannot find a valid baseurl for repo: base/7/x86_64
------
Dockerfile:6
--------------------
4 | ENV WORKPATH /usr/local
5 | WORKDIR $WORKPATH
6 | >>> RUN yum -y install vim net-tools wget
7 | CMD /bin/bash
8 |
--------------------
ERROR: failed to solve: process "/bin/sh -c yum -y install vim net-tools wget" did not complete successfully: exit code: 1
尝试过更换yum源、检查网络等等,均无法解决。
最后将docker 重启了,但是生产环境需要谨慎重启docker
systemctl restart docker
再次执行
[root@test hw]# docker build -t cento7:1.0 .
[+] Building 64.5s (5/6)
=> [internal] load .dockerignore 0.0s 0.0s
[+] Building 64.7s (5/6) 0.0s 0.0s rnal] load build definition from Dockerfile 0.0s 0.0s
=> [internal] load .dockerignore 0.0s 0.0s 0.0sernal] load metadata for docker.io/library/centos:7 0.0s 0.0s
=> => transferring context: 2B 0.0s 0.0s 0.0sED [2/3] WORKDIR /usr/local 0.0s 0.0s
=> [internal] load build definition from Dockerfile 64.5s 64.2s 0.0s Running transaction check
=> => transferring dockerfile: 302B 0.0s Transaction test succeeded
=> [internal] load metadata for docker.io/library/centos:7 0.0s Installing : gpm-libs-1.20.7-6.el7.x86_64 1/35
=> [1/3] FROM docker.io/library/centos:7 0.0s
=> CACHED [2/3] WORKDIR /usr/local 0.0s
=> [3/3] RUN yum -y install vim net-tools wget [+] Building 64.8s (5/6) Running transaction check => [internal] load .dockerignore 0.0s Running transaction test => => transferring context: 2B 0.0s Transaction test succeeded => [internal] load build definition from Dockerfile 0.0s Running transaction => => transferring dockerfile: 302B 0.0s Installing : gpm-libs-1.20.7-6.el7.x86_64 1/35 => [internal] load metadata for docker.io/library/centos:7 0.0s Installing : 2:vim-filesystem-7.4.629-8.el7_9.x86_64 2/35 => [1/3] FROM docker.io/library/centos:7 0.0s
=> CACHED [2/3] WORKDIR /usr/local [+] Building 102.5s (7/7) FINISHED
=> [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 302B 0.0s
=> [internal] load metadata for docker.io/library/centos:7 0.0s => [1/3] FROM docker.io/library/centos:7 0.0s
=> CACHED [2/3] WORKDIR /usr/local 0.0s => [3/3] RUN yum -y install vim net-tools wget 90.4s
=> exporting to image 11.9s => => exporting layers 11.9s
=> => writing image sha256:9c42ab93536027309742507295ac8481238448ce43c8cd0719c1750862a102a3 0.0s => => naming to docker.io/library/cento7:1.0
发现问题解决。文章来源:https://www.toymoban.com/news/detail-728429.html
[root@test hw]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE
cento7 1.0 9c42ab935360 18 seconds ago 469MB
hello-my-word latest 280551f2b1ed 2 hours ago 861kB
centos 7 eeb6ee3f44bd 21 months ago 204MB
可参考学习!文章来源地址https://www.toymoban.com/news/detail-728429.html
到了这里,关于dockerfile报错:“/bin/sh -c yum -y install vim net-tools wget“ did not complete successfully: exit code的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!