如題。真心求教,謝過各位。有遇到過的或者高手,請不吝賜教問題是如何解決的!
直奔主題:
環境:
Distributor ID: CentOS
Description: CentOS release 6.7 (Final)
Release: 6.7
Dockerfile:
# Version : 0.0.1
FROM centos
MAINTAINER sql "[email protected]"
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 "[email protected]"
---> 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
uj5u.com熱心網友回復:
docker 默認都是機遇ubuntu,你用yum能用嗎?debian,ubuntu用apt管理包。uj5u.com熱心網友回復:
你好!感謝回復。我用的是rhel。系統版本是centos7.沒用ubuntu。uj5u.com熱心網友回復:
我是說,是docker實體的Linux模板,你說的也是docker內的系統嗎?
uj5u.com熱心網友回復:
你指的實體是docker容器的基礎鏡像嗎?我是想用centos,結果是報以上錯誤。現在我把基礎鏡像改為Ubuntu試試。uj5u.com熱心網友回復:
抱歉,是我沒看清楚,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 "[email protected]"
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
你試試看
uj5u.com熱心網友回復:
還是不行,我看報錯意思應該是源的問題嗎?uj5u.com熱心網友回復:
報錯日志含這段Cannot find a valid baseurl for repo: base/7/x86_64Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was
uj5u.com熱心網友回復:
是的,我正在添加了源以后成功了。
uj5u.com熱心網友回復:
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 "[email protected]"
---> 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
[code]
[root@e5627a103c6b /]# whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx[/code]
[code]
[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
[/code]
uj5u.com熱心網友回復:
是不是你的Dockerfile檔案的第五行問題,你的RUN寫成了“RUn” 導致的問題呢uj5u.com熱心網友回復:
兩種方式:1. 在yum install 之前加一條RUN yum update
2. 在yum install 之前 加上 RUN ADD url(源的檔案) /etc。。。。。。 鏡像源檔案位置
3. 在yum update && yum update install
uj5u.com熱心網友回復:
在打包成鏡像時 yum list和cache都會清除,所以你得先 yum update轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/54880.html
標籤:Docker
上一篇:docker啟動不了:docker-containerd.sock: timeout
下一篇:hadoop環境變數配置
