Gitlab CI - docker: command not found

2019-06-18 23:12发布

I am trying to build my docker image within the gitlab ci pipeline.

However it is not able to find the docker command.

/bin/bash: line 69: docker: command not found ERROR: Job failed: error executing remote command: command terminated with non-zero exit code: Error executing in Docker Container: 1

.gitlab-ci.yml

stages:
  - quality
  - test
  - build
  - deploy

image: node:8.11.3

services:
  - mongo
  - docker:dind

before_script:
- npm install

quality:
  stage: quality
  script:
  - npm run-script lint

test:
  stage: test
  script:
  - npm run-script test

build:
  stage: build
  script:
  - docker build -t server .

deploy:
  stage: deploy
  script:
  - echo "TODO deploy push docker image"

3条回答
唯我独甜
2楼-- · 2019-06-18 23:42

you need to choose an image including docker binaries

image: gitlab/dind

services:
  - docker:dind
查看更多
Root(大扎)
3楼-- · 2019-06-18 23:50

additional to Hieu Vo

image: docker:latest

stages:
  - build
  - release

services:
  - docker:dind
查看更多
放荡不羁爱自由
4楼-- · 2019-06-19 00:00

Problem here is that node docker image does not embed docker binaries.

Two possibilities :

  • split stages to two jobs. One using node images for quality and test, one using docker image for building and deploying. See jobs documentation.

  • build a custom docker image that embed both node and docker and use this image to build your repo.

Note that in both case you will have to enable docker inside your agent. See documentation.

查看更多
登录 后发表回答