docker构建镜像问题求助

sql 2017-12-13 03:56:10
如题。真心求教,谢过各位。有遇到过的或者高手,请不吝赐教问题是如何解决的!
直奔主题:
环境:
Distributor ID: CentOS
Description: CentOS release 6.7 (Final)
Release: 6.7
Dockerfile:
# Version : 0.0.1
FROM centos
MAINTAINER sql "sqlwlh@163.com"
RUN yum -y install nginx
RUn echo 'I am in your container!'
EXPOSE 80
描述:
服务器网络正常。初步怀疑是yum源问题,但是单独执行"yum -y install nginx"正常。百度无果。
报错:
Sending build context to Docker daemon 4.096 kB
Sending build context to Docker daemon
Step 0 : FROM centos
---> e74c56fbba84
Step 1 : MAINTAINER sql "sqlwlh@163.com"
---> Using cache
---> 978c5cb493dc
Step 2 : RUN yum -y install nginx
---> Running in 568c25bd90dc
Loaded plugins: fastestmirror, ovl


One of the configured repositories failed (Unknown),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:

1. Contact the upstream for the repository and get them to fix the problem.

2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).

3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...

4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:

yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>

5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:

yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was
12: Timeout on http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container: (28, 'Resolving timed out after 30546 milliseconds')
The command '/bin/sh -c yum -y install nginx' returned a non-zero code: 1
...全文
863 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
just-go 2018-01-31
  • 打赏
  • 举报
回复
两种方式: 1. 在yum install 之前加一条RUN yum update 2. 在yum install 之前 加上 RUN ADD url(源的文件) /etc。。。。。。 镜像源文件位置 3. 在yum update && yum update install
雨焰 2018-01-29
  • 打赏
  • 举报
回复
是不是你的Dockerfile文件的第五行问题,你的RUN写成了“RUn” 导致的问题呢
什么都不能 2017-12-19
  • 打赏
  • 举报
回复

sudo docker build -t centos123:IMG -f /home/upload/tomcat/server/pfms/test.txt /home/upload/tomcat/server/pfms
Sending build context to Docker daemon 156.5 MB
Sending build context to Docker daemon
Step 0 : FROM centos
 ---> 358bf47a7a64
Step 1 : MAINTAINER sql "sqlwlh@163.com"
 ---> Using cache
 ---> 68f0d48f5880
Step 2 : RUN yum -y update
 ---> Using cache
 ---> fe30f640f1d1
Step 3 : ADD a.txt /etc/yum.repos.d/nginx.repo
 ---> Using cache
 ---> 85a35be996b0
Step 4 : RUN yum -y install nginx
 ---> Using cache
 ---> 5b0512c199db
Step 5 : RUN echo 'I am in your container!'
 ---> Using cache
 ---> 91b4eaae9321
Step 6 : EXPOSE 80
 ---> Using cache
 ---> 1002243766e8
Successfully built 1002243766e8

[root@e5627a103c6b /]# whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx

[root@e5627a103c6b sbin]# ps -ef|grep nginx
root        45     1  0 13:07 ?        00:00:00 nginx: master process ./nginx
nginx       46    45  0 13:07 ?        00:00:00 nginx: worker process
root        50     1  0 13:08 ?        00:00:00 grep --color=auto nginx
什么都不能 2017-12-19
  • 打赏
  • 举报
回复
引用 6 楼 sunqingliang1 的回复:
还是不行,我看报错意思应该是源的问题吗?
是的,我正在添加了源以后成功了。
sql 2017-12-18
  • 打赏
  • 举报
回复
报错日志含这段Cannot find a valid baseurl for repo: base/7/x86_64 Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was
sql 2017-12-18
  • 打赏
  • 举报
回复
还是不行,我看报错意思应该是源的问题吗?
什么都不能 2017-12-15
  • 打赏
  • 举报
回复
引用 4 楼 sunqingliang1 的回复:
你指的实例是docker容器的基础镜像吗?我是想用centos,结果是报以上错误。现在我把基础镜像改为Ubuntu试试。
抱歉,是我没看清楚,dockerfile已经是from centos了,我刚试了下,你看这样是否可以 dockerfile 同目录,我的随便整了个文件a.txt
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
dockerfile 我随便一个名字test.txt
# Version : 0.0.1
FROM centos
MAINTAINER sql "sqlwlh@163.com"
RUN yum -y update
ADD a.txt /etc/yum.repos.d/nginx.repo
RUN yum -y install nginx
RUn echo 'I am in your container!'
EXPOSE 80
随便放到了一个目录了里,centos 70多M,down的时候有点慢
sudo docker build -t centos123:IMG -f /home/upload/tomcat/server/pfms/test.txt /home/upload/tomcat/server/pfms
你试试看
sql 2017-12-14
  • 打赏
  • 举报
回复
你好!感谢回复。我用的是rhel。系统版本是centos7.没用ubuntu。
sql 2017-12-14
  • 打赏
  • 举报
回复
你指的实例是docker容器的基础镜像吗?我是想用centos,结果是报以上错误。现在我把基础镜像改为Ubuntu试试。
什么都不能 2017-12-14
  • 打赏
  • 举报
回复
引用 2 楼 sunqingliang1 的回复:
你好!感谢回复。我用的是rhel。系统版本是centos7.没用ubuntu。
我是说,是docker实例的Linux模板,你说的也是docker内的系统吗?
什么都不能 2017-12-13
  • 打赏
  • 举报
回复
docker 默认都是机遇ubuntu,你用yum能用吗?debian,ubuntu用apt管理包。

1,163

社区成员

发帖
与我相关
我的任务
社区描述
Docker是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的Linux 机器上,也可以实现虚拟化。
社区管理员
  • Docker
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧