简体   繁体   English

Gitlab-ci可以构建docker映像,但无法运行它

[英]Gitlab-ci can build docker image, but can't run it

I'am new to gitlab-ci. 我是gitlab-ci的新手。 Probably i have problem with git-lab runner or on my gitlab-ci.yml file. 可能我的git-labrunner或gitlab-ci.yml文件有问题。 Script on my image use whois command. 我图像上的脚本使用whois命令。

gitlab-ci.yml gitlab-ci.yml

image: docker:18

services:
 - docker:dind 

stages:
 - build
 - test

before_script:
 - docker info

build:
 stage: build
 script:
  - echo "build"
  - docker build -t image.

test:
 stage: test
 script:
  - echo "test"
  - docker run -i image 185.33.37.131

test returns 测试回报

$ docker run -i image 185.33.37.131
Unable to find image 'image:latest' locally
docker: Error response from daemon: pull access denied for image, repository does not exist or may require 'docker login'.
See 'docker run --help'.
ERROR: Job failed: exit code 125

docker info returns suspect value 码头工人信息返回可疑值

$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
.
.
.
Successfully built 64f54ee594e7
Successfully tagged image:latest

You are building the image in one GitLab job and then trying to run it in another one. 您正在一个GitLab作业中构建映像,然后尝试在另一个作业中运行它。 Each job is isolated from the others, so the image would no longer exist in the test job. 每个作业都是彼此隔离的,因此该映像将不再存在于测试作业中。 You should push the image to a docker registry after building it and then pull it from the registry when you want to run it. 构建映像后,应将其推送到docker注册表,然后在要运行它时将其从注册表中拉出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM