File tree Expand file tree Collapse file tree 1 file changed +42
-1
lines changed Expand file tree Collapse file tree 1 file changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -321,4 +321,45 @@ check_interval = 0
321
321
322
322
```
323
323
ERROR: error during connect: Get http://docker:2375/v1.40/info: dial tcp: lookup docker on 8.8.8.8:53: no such host
324
- ```
324
+ ```
325
+
326
+ ### CI 中使用编译提交镜像
327
+
328
+ 下面是 [ 官方仓库 Docker.gitlab-ci.yml] ( https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Docker.gitlab-ci.yml ) 模板
329
+
330
+ ``` yml
331
+ docker-build-master :
332
+ # Official docker image.
333
+ image : docker:latest
334
+ stage : build
335
+ services :
336
+ - docker:dind
337
+ before_script :
338
+ - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
339
+ script :
340
+ - docker build --pull -t "$CI_REGISTRY_IMAGE" .
341
+ - docker push "$CI_REGISTRY_IMAGE"
342
+ only :
343
+ - master
344
+ ` ` `
345
+
346
+ - ` CI_REGISTRY_USER` Github 用户名 Example: `wangchujiang`
347
+ - ` CI_REGISTRY_PASSWORD` 密码(personal_access_tokens),密码是需要通过 [Gitlab > User Settings > Access Tokens > Add a personal access token](http://g.showgold.cn/-/profile/personal_access_tokens)) 生成一个 `personal_access_tokens` 而不是真正的密码
348
+ - `CI_REGISTRY` Registry 地址 Example : ` 192.168.188.222:8070`
349
+ - `CI_REGISTRY_IMAGE` Example : ` 192.168.188.222:5008/docker/docker-static-service-template`
350
+
351
+ ` ` ` yml
352
+ docker-build:
353
+ # Official docker image.
354
+ image: docker:latest
355
+ stage: build
356
+ services:
357
+ - docker:dind
358
+ before_script:
359
+ - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
360
+ script:
361
+ - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
362
+ - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
363
+ except:
364
+ - master
365
+ ` ` `
You can’t perform that action at this time.
0 commit comments