Gitlab CI - docker: command not found

一世执手 提交于 2019-12-08 16:23:32

问题


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"

回答1:


you need to choose an image including docker binaries

image: gitlab/dind

services:
  - docker:dind



回答2:


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.




回答3:


additional to Hieu Vo

image: docker:latest

stages:
  - build
  - release

services:
  - docker:dind


来源:https://stackoverflow.com/questions/51196435/gitlab-ci-docker-command-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!