我使用Kubernetes设置了我的Gitlab示例来部署,并使用Kubernetes集群执行CI。Kubernetes由Gitlab管理,所以我自己并没有接触过Kubernetes。Gitlab安装了四个可用包:Helm Tiller Ingress、Cert-Manager、Prometheus和GitLab Runner。
我使用以下教程在准系统服务器上安装了Kubernetes集群:https://vitux.com/install-and-deploy-kubernetes-on-ubuntu/。服务器的操作系统是Ubuntu 18.04 minimum。我发现Gitlab无法在Kubernetes 1.16版本上安装Helm Tiller,所以我在服务器上安装了Kubernetes 1.15.5-00版本。
问题:
我有一个项目,我想构建一个Docker镜像。我尝试使用dind服务来构建docker镜像,并使用部署在kubernetes平台上的gitlab runner。
生成过程失败,输出如下:
Running with gitlab-runner 12.1.0 (de7731dd)
on runner-gitlab-runner-699dc9bcc8-sgmcw -YPHFGCL
Using Kubernetes namespace: gitlab-managed-apps
Using Kubernetes executor with image docker:stable ...
Waiting for pod gitlab-managed-apps/runner--yphfgcl-project-97-concurrent-0qj6sn to be running, status is Pending
Waiting for pod gitlab-managed-apps/runner--yphfgcl-project-97-concurrent-0qj6sn to be running, status is Pending
Waiting for pod gitlab-managed-apps/runner--yphfgcl-project-97-concurrent-0qj6sn to be running, status is Pending
Running on runner--yphfgcl-project-97-concurrent-0qj6sn via runner-gitlab-runner-699dc9bcc8-sgmcw...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/sadion/ci-test/.git/
Created fresh repository.
From https://git.sadion.net/sadion/ci-test
* [new branch] master -> origin/master
Checking out d179001c as master...
Skipping Git submodules setup
$ docker --version
Docker version 19.03.4, build 9013bf583a
$ docker build -t $TEST_NAME .
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
ERROR: Job failed: command terminated with exit code 1
字符串
源文件:
我使用的Dockerfile非常简单,也是有效的,因为我可以在本地机器上构建镜像:
FROM httpd:2.4
COPY ./index.html /usr/local/apache2/htdocs/
型
我使用的.gitlab-ci.yml
文件是:
image: docker:stable
variables:
TEST_NAME: local/test
services:
- docker:dind
stages:
- build
before_script:
- docker info
build_docker_image:
stage: build
before_script:
- docker --version
script:
- docker build -t $TEST_NAME .
tags:
- build
- kubernetes
型
尝试导出DOCKER_HOST
我还尝试导出DOCKER_HOST
变量。但是,配置后,我得到了相同的错误:
image: docker:stable
variables:
TEST_NAME: local/test
DOCKER_HOST: tcp://localhost:2375
services:
- docker:dind
stages:
- build
before_script:
- docker info
build_docker_image:
stage: build
before_script:
- docker --version
script:
- docker build -t $TEST_NAME .
tags:
- build
- kubernetes
型
runner的输出是:
Running with gitlab-runner 12.1.0 (de7731dd)
on runner-gitlab-runner-699dc9bcc8-sgmcw -YPHFGCL
Using Kubernetes namespace: gitlab-managed-apps
Using Kubernetes executor with image docker:stable ...
Waiting for pod gitlab-managed-apps/runner--yphfgcl-project-97-concurrent-042nmk to be running, status is Pending
Waiting for pod gitlab-managed-apps/runner--yphfgcl-project-97-concurrent-042nmk to be running, status is Pending
Waiting for pod gitlab-managed-apps/runner--yphfgcl-project-97-concurrent-042nmk to be running, status is Pending
Running on runner--yphfgcl-project-97-concurrent-042nmk via runner-gitlab-runner-699dc9bcc8-sgmcw...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/sadion/ci-test/.git/
Created fresh repository.
From https://git.sadion.net/sadion/ci-test
* [new branch] master -> origin/master
Checking out 57b6be1d as master...
Skipping Git submodules setup
$ docker --version
Docker version 19.03.4, build 9013bf583a
$ docker build -t $TEST_NAME .
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
ERROR: Job failed: command terminated with exit code 1
型
1条答案
按热度按时间4bbkushb1#
所以我找到了解决办法。我认为问题在于我没有指定证书目录。通过将目录更改为
""
,它开始工作。字符串