使用dockerfile提取git存储库时连接被拒绝 [英] connection refused when using dockerfile to pull git repository
问题描述
kubernetes的本地设置: Mac OS
Local setup for kubernetes: Mac OS
Docker for desktop >> kubernetes >> traefik >> Gitea
该gitea已安装在集群中,并通过treafik作为集群IP服务入口公开,可以在 http://gitea.local .到这里一切都很顺利.
The gitea is installed in the cluster and exposed as clusterIP service ingresses through treafik which is accessible at http://gitea.local. Everything is butter smooth till here.
痛苦:
现在我正在创建一个dockerfile并使用docker build来构建映像.该dockerfile试图从 http://gitea.local 克隆存储库.问题是我一直都在拒绝连接.
Now i am creating a dockerfile and using a docker build to build an image. This dockerfile is trying to clone a repository from http://gitea.local. The problem is i am getting connection refused all the times.
RUN mkdir -p apps sites/assets/css \
&& cd apps \
&& git clone http://gitea.local/inviadmin/testing.git
然后我只是在dockerfile中尝试了RUN curl http://gitea.local
来进行调试并得到了相同的结果:
Then i simply tried RUN curl http://gitea.local
from inside dockerfile just to debug and got the same:
curl: (7) Failed to connect to gitea.local port 80: Connection refused
如果我从dockerfile中卷曲google.com
,则其工作正常.我们非常感谢您的帮助.
if i curl google.com
from dockerfile its working. Any help is strongly appreciated.
Dockerfile:
# syntax = docker/dockerfile:1.0-experimental
FROM bitnami/python:3.7-prod
ENV NVM_DIR=/root/.nvm
ENV NODE_VERSION=12.18.3
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN install_packages wget \
&& wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh \
&& chmod +x install.sh \
&& ./install.sh \
&& . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} \
&& nvm use v${NODE_VERSION} && npm install -g yarn
RUN install_packages \
# when using ssh
git openssh-client openssh-server iputils-ping
#git
ARG GIT_BRANCH=master
#RUN ping host.docker.internal
RUN mkdir -p apps sites/assets/css \
&& cd apps \
&& git clone http://gitea.local/inviadmin/test.git --branch $GIT_BRANCH
FROM nginx:latest
COPY --from=0 /home/test/sample/sites /var/www/html/
COPY --from=0 /var/www/error_pages /var/www/
COPY build/nginx/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template
COPY build/entry/docker-entrypoint.sh /
RUN apt-get update && apt-get install -y rsync && apt-get clean \
&& echo "#!/bin/bash" > /rsync \
&& chmod +x /rsync
VOLUME [ "/assets" ]
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
推荐答案
我测试了您的dockerfile,结果如下
I tested your dockerfile and here's the outcome
由于您遇到的唯一问题是git pull,因此我选择仅使用以下几行.
Since the only part you were having issue was the git pull, i chose to use the following lines only.
从构建中注意到,对于以下命令,如何将条目添加到/etc/hosts才生效. 如果问题仍然存在,则建议您开始查看gitea容器的日志.
Notice from the build that how adding entry to the /etc/hosts took effect for the following commands. If the issue still persists then i suggest you start looking into the gitea container's logs.
这篇关于使用dockerfile提取git存储库时连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!