Run docker-compose build in .gitlab-ci.yml

前端 未结 9 1220
臣服心动
臣服心动 2020-12-12 14:06

I have a .gitlab-ci.yml file which contains following:

image: docker:latest

services:
  - docker:dind
         


        
9条回答
  •  眼角桃花
    2020-12-12 14:54

    Following the official documentation:

    # .gitlab-ci.yml
    image: docker
    services:
      - docker:dind    
    build:
      script:
        - apk add --no-cache docker-compose
        - docker-compose up -d
    

    Sample docker-compose.yml:

    version: "3.7"
    services:
      foo:
        image: alpine
        command: sleep 3
      bar:
        image: alpine
        command: sleep 3
    

    We personally do not follow this flow anymore, because you loose control about the running containers and they might end up running endless. This is because of the docker-in-docker executor. We developed a python-script as a workaround to kill all old containers in our CI, which can be found here. But I do not suggest to start containers like this anymore.

提交回复
热议问题