生成docker映像时找不到repo:base/7/x86_64的有效baseurl

生成docker映像时找不到repo:base/7/x86_64的有效baseurl,docker,centos,dockerfile,Docker,Centos,Dockerfile,我想基于centos 7构建一个docker映像,dockerfile如下 FROM centos MAINTAINER pengji jipeng92@gmail.com WORKDIR /root COPY MySQL-5.6.26 /mysql RUN yum update RUN yum -y install java-1.8.0-openjdk wget httpd php php-mysqlnd /mysql/* RUN mysql_install_db --user=mysql

我想基于centos 7构建一个docker映像,dockerfile如下

FROM centos
MAINTAINER pengji jipeng92@gmail.com
WORKDIR /root
COPY MySQL-5.6.26 /mysql
RUN yum update
RUN yum  -y install java-1.8.0-openjdk wget httpd php php-mysqlnd /mysql/*
RUN mysql_install_db --user=mysql
ENV MYSQL_ROOT_PASSWORD=root
ENV MYCAT_USER mycat
ENV MYCAT_PASS mycat
RUN wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.64/bin/apache-tomcat-7.0.64.tar.gz
RUN tar xvf apache-tomcat-7.0.64.tar.gz -C /usr/local/ && mv /usr/local/apache-tomcat-7.0.64/ /usr/local/tomcat
RUN wget http://code.taobao.org/svn/openclouddb/downloads/old/MyCat-Sever-1.2/Mycat-server-1.2-GA-linux.tar.gz
RUN mkdir /usr/local/mycat && tar xvf Mycat-server-1.2-GA-linux.tar.gz -C /usr/local/mycat && useradd mycat && \
chown -R mycat.mycat /usr/local/mycat && chmod a+x /usr/local/mycat/bin/*
EXPOSE 8080 8066 9066
COPY /home/jipeng/dockerfiles/dataguru/java_tomcat_mysql/startup.sh /root/startup.sh
RUN chmod a+x /root/startup.sh
ENTRYPOINT /root/startup.sh
Sending build context to Docker daemon   317 MB
Step 0 : FROM centos
 ---> bb3d629a7cbc
Step 1 : MAINTAINER pengji jipeng92@gmail.com
 ---> Using cache
 ---> cdbbb4de4d8e
Step 2 : WORKDIR /root
 ---> Using cache
 ---> 6d6a40194219
Step 3 : COPY MySQL-5.6.26 /mysql
 ---> Using cache
 ---> 7cfa1ec8c6b9
Step 4 : RUN yum update
 ---> Running in fc44891ca20a
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. Disable the repository, 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>

 4. 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
然后通过命令构建

docker build -t pengji/mycat .  
过程如下

FROM centos
MAINTAINER pengji jipeng92@gmail.com
WORKDIR /root
COPY MySQL-5.6.26 /mysql
RUN yum update
RUN yum  -y install java-1.8.0-openjdk wget httpd php php-mysqlnd /mysql/*
RUN mysql_install_db --user=mysql
ENV MYSQL_ROOT_PASSWORD=root
ENV MYCAT_USER mycat
ENV MYCAT_PASS mycat
RUN wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.64/bin/apache-tomcat-7.0.64.tar.gz
RUN tar xvf apache-tomcat-7.0.64.tar.gz -C /usr/local/ && mv /usr/local/apache-tomcat-7.0.64/ /usr/local/tomcat
RUN wget http://code.taobao.org/svn/openclouddb/downloads/old/MyCat-Sever-1.2/Mycat-server-1.2-GA-linux.tar.gz
RUN mkdir /usr/local/mycat && tar xvf Mycat-server-1.2-GA-linux.tar.gz -C /usr/local/mycat && useradd mycat && \
chown -R mycat.mycat /usr/local/mycat && chmod a+x /usr/local/mycat/bin/*
EXPOSE 8080 8066 9066
COPY /home/jipeng/dockerfiles/dataguru/java_tomcat_mysql/startup.sh /root/startup.sh
RUN chmod a+x /root/startup.sh
ENTRYPOINT /root/startup.sh
Sending build context to Docker daemon   317 MB
Step 0 : FROM centos
 ---> bb3d629a7cbc
Step 1 : MAINTAINER pengji jipeng92@gmail.com
 ---> Using cache
 ---> cdbbb4de4d8e
Step 2 : WORKDIR /root
 ---> Using cache
 ---> 6d6a40194219
Step 3 : COPY MySQL-5.6.26 /mysql
 ---> Using cache
 ---> 7cfa1ec8c6b9
Step 4 : RUN yum update
 ---> Running in fc44891ca20a
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. Disable the repository, 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>

 4. 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
将生成上下文发送到Docker守护程序317 MB
步骤0:从centos开始
--->bb3d629a7cbc
步骤1:维护人员彭吉jipeng92@gmail.com
--->使用缓存
--->cdbbb4de4d8e
步骤2:WORKDIR/root
--->使用缓存
--->6d6a40194219
第三步:复制MySQL-5.6.26/MySQL
--->使用缓存
--->7cfa1ec8c6b9
步骤4:运行yum更新
--->在fc44891ca20a中运行
加载的插件:FastTestMirror、ovl
其中一个配置的存储库失败(未知),
而且yum没有足够的缓存数据继续。在这一点上,唯一的
百胜可以做的安全事情就是失败。有几种方法可以“修复”此问题:
1.联系上游的存储库,让他们解决问题。
2.为存储库重新配置baseurl/etc,以指向工作
上游如果您使用的是较新的
存储库(以及
上一个发行版的包仍然有效)。
3.禁用存储库,以便默认情况下yum不会使用它。那么百胜将
只需忽略存储库,直到您再次永久启用或使用它
--临时使用的enablerepo:
yum配置管理器--禁用
4.如果失败的存储库不可用,请将其配置为跳过。
请注意,yum将尝试联系repo。当它运行大多数命令时,
因此,每次都必须尝试失败(因此,百胜将是非常重要的)
较慢)。如果这是一个非常暂时的问题,这通常是一个很好的解决方案
妥协:
yum config manager--save--setopt=.skip_if_unavailable=true
找不到repo:base/7/x86\u 64的有效baseurl


我怎样才能解决这个问题?谢谢。

也许您设置了http\U代理,但代理服务器未访问。
取消设置http_代理

通过添加一些防火墙规则解决了此问题

sudo firewall-cmd --permanent --zone=trusted --add-interface=docker0
sudo firewall-cmd --permanent --zone=FedoraWorkstation --add-masquerade

参考:

我也遇到了同样的问题,因为docker0接口上缺少伪装iptables规则

我通过tcpdump注意到,容器试图使用自己的ip退出

.872491 IP(tos 0x0,ttl 63,id 44842,偏移量0,标志[DF],协议TCP (6) ,长度60)

172.17.0.20.39146>147.75.69.225.80:旗帜,cksum 0x856e,序号241251313,win 29200,选项[mss 1460,萨克克,TS val 67935451 ecr 0,nop,wscale 7],长度0

我在/etc/docker/daemon.json中添加了以下选项,最后容器到达了外部世界

{
     ...
     "ip-masq": true,
     ... 
}
确保deamon--iptables选项设置为true,否则将不会添加伪装规则

不管怎样,看看

或者,也可以创建带有伪装的自定义网络,并将其与容器关联


“流程如下”什么?这里没有问题。编辑您的问题。对不起,我已经添加了其余内容。您是否支持代理?(如中所述)我也遇到了同样的问题。你是怎么解决的?这救了我的命!