Reputation: 21
I want to build a docker image based on centos 7,the dockerfile is as follows
FROM centos
MAINTAINER pengji [email protected]
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
then build by command
docker build -t pengji/mycat .
the process is as follows
Sending build context to Docker daemon 317 MB
Step 0 : FROM centos
---> bb3d629a7cbc
Step 1 : MAINTAINER pengji [email protected]
---> 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
Cannot find a valid baseurl for repo: base/7/x86_64
How can I solve this problem? Thank you.
Upvotes: 1
Views: 11374
Reputation: 625
add --network=host to docker build works for me
docker build --network=host -t name .
Upvotes: 2
Reputation: 170
This may be solves by fixing the iptables.
Run these commands:
sudo iptables -N DOCKER
sudo iptables -N DOCKER-ISOLATION-STAGE-1
sudo iptables -N DOCKER-ISOLATION-STAGE-2
sudo iptables -N DOCKER-USER
sudo iptables -A FORWARD -j DOCKER-USER
sudo iptables -A FORWARD -j DOCKER-ISOLATION-STAGE-1
sudo iptables -A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -o docker0 -j DOCKER
sudo iptables -A FORWARD -i docker0 ! -o docker0 -j ACCEPT
sudo iptables -A FORWARD -i docker0 -o docker0 -j ACCEPT
sudo iptables -A DOCKER-ISOLATION-STAGE-1 -i docker0 ! -o docker0 -j DOCKER-ISOLATION-STAGE-2
sudo iptables -A DOCKER-ISOLATION-STAGE-1 -j RETURN
sudo iptables -A DOCKER-ISOLATION-STAGE-2 -o docker0 -j DROP
sudo iptables -A DOCKER-ISOLATION-STAGE-2 -j RETURN
sudo iptables -A DOCKER-USER -j RETURN
Upvotes: 0
Reputation: 9
I had same problem, in my case due to MASQUERADE iptables rule missing on docker0 interface.
I noticed by tcpdump that container was trying to get out with its own ip
.872491 IP (tos 0x0, ttl 63, id 44842, offset 0, flags [DF], proto TCP (6), length 60)
172.17.0.2.39146 > 147.75.69.225.80: Flags [S], cksum 0x856e, seq 241251313, win 29200, options [mss 1460,sackOK,TS val 67935451 ecr 0,nop,wscale 7], length 0
I added following option in /etc/docker/daemon.json and finally the container have reached external world
{
...
"ip-masq": true,
...
}
Be sure that deamon --iptables option is set to true otherwise the MASQUERADE rule it will not be added.
Anyway look at
Alternatively it is possible to create a custom network with masquerading and associate it to the container
Upvotes: 0
Reputation: 1739
Solved it by adding some firewall rules
sudo firewall-cmd --permanent --zone=trusted --add-interface=docker0
sudo firewall-cmd --permanent --zone=FedoraWorkstation --add-masquerade
Ref: https://fedoramagazine.org/docker-and-fedora-32/
Upvotes: 2
Reputation: 41
maybe you set http_proxy and your proxy server is unreached. unset http_proxy
Upvotes: 2