简体   繁体   中英

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

I'am new to gitlab-ci. Probably i have problem with git-lab runner or on my gitlab-ci.yml file. Script on my image use whois command.

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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