2017-05-08 21 views
5

Projemi çalıştırmak için docker da dahil olmak üzere ilk GitLab Ci Boru Hattı kurulumumu yapıyorum. Boru hattımı birkaç aşamaya ayırmak istedim, böylece "derleme", "test et" ve "temiz oluşturma" oluşturdum. Bu senaryo her şey Docker runner ile GitLab Ci - Çoklu Aşamalar

çalışıyor:

stages: 
    - build 
    - test 
    - clean 

image: docker:latest 

services: 
    - docker:dind 

before_script: 
    - export RELEASE=${CI_BUILD_REF_NAME} 
    - docker version 

build: 
    stage: build 
    tags: 
    - sendis-dind 
    script: 
    - echo "Hallo in Build Stage" 

test: 
    stage: test 
    tags: 
    - sendis-dind 
    script: 
    - echo "Hallo in TEST Stage" 

clean-build: 
    stage: clean 
    tags: 
    - sendis-dind 
    script: 
    - echo "Hallo beim Clean Up" 
    when: always 

tamamı 3 aşamaları

başarıyla çalıştırılır ancak bu başarısız: İkinci aşamada aşağıdaki mesaj ile

stages: 
    - build 
    - test 
    - clean 

image: docker:latest 

services: 
    - docker:dind 

before_script: 
    - export RELEASE=${CI_BUILD_REF_NAME} 
    - docker version 

build: 
    stage: build 
    tags: 
    - sendis-dind 
    script: 
    - apk add --update py-pip 
    - pip install docker-compose 
    - docker --version 
    - docker-compose --version 
    - docker-compose -p ${RELEASE} build 
    - docker-compose -p ${RELEASE} up -d 

test: 
    stage: test 
    tags: 
    - sendis-dind 
    script: 
    - docker exec ${RELEASE}_phpfpm_1 bash -c "cd /app; composer install; make runTests" 

clean-build: 
    stage: clean 
    tags: 
    - sendis-dind 
    script: 
    - docker-compose -p ${RELEASE} down --volumes 
    when: always 

Running with gitlab-ci-multi-runner 9.1.1 (6104325) 
    on sendis-dind-runner (8b9eca1e) 
Using Docker executor with image docker:latest ... 
Starting service docker:dind ... 
Pulling docker image docker:dind ... 
Using docker image docker:dind ID=sha256:559dd16b4e0a64d9de2447d3de234743046443f770bf5226f45f9b7f9c68887b for docker service... 
ERROR: Preparation failed: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 
Will be retried in 3s ... 
Using Docker executor with image docker:latest ... 
Starting service docker:dind ... 
Pulling docker image docker:dind ... 
Using docker image docker:dind ID=sha256:559dd16b4e0a64d9de2447d3de234743046443f770bf5226f45f9b7f9c68887b for docker service... 
ERROR: Preparation failed: Error response from daemon: Conflict. The container name "/runner-8b9eca1e-project-140-concurrent-0-docker" is already in use by container "db166f7894856c245c6a4f5318326c5f3b6ab82d82157961d18b079444153113". You have to remove (or rename) that container to be able to reuse that name. 
Will be retried in 3s ... 
Using Docker executor with image docker:latest ... 
Starting service docker:dind ... 
Pulling docker image docker:dind ... 
Using docker image docker:dind ID=sha256:559dd16b4e0a64d9de2447d3de234743046443f770bf5226f45f9b7f9c68887b for docker service... 
ERROR: Preparation failed: Error response from daemon: Conflict. The container name "/runner-8b9eca1e-project-140-concurrent-0-docker" is already in use by container "db166f7894856c245c6a4f5318326c5f3b6ab82d82157961d18b079444153113". You have to remove (or rename) that container to be able to reuse that name. 
Will be retried in 3s ... 
ERROR: Job failed (system failure): Error response from daemon: Conflict. The container name "/runner-8b9eca1e-project-140-concurrent-0-docker" is already in use by container "db166f7894856c245c6a4f5318326c5f3b6ab82d82157961d18b079444153113". You have to remove (or rename) that container to be able to reuse that name. 

cevap

0

Farklı aşamalar yalnızca birbirleriyle eserler paylaşır, ancak bunlar ayrı docker konteynerleridir. Bu, oluşturma aşamasında docker-compose up -d çalıştırırsanız, kapsayıcıların test aşamasında çalışmadığı anlamına gelir.

Dind'i gitlab-ci ile birleştirmek yalnızca çok özel kullanım durumlarında gereklidir. Senin durumunda, hiç birşeye ihtiyacın yok. Gitlab-ci zaten docker üzerinde çalışıyor olduğundan, php-fpm görüntüsünü test adımınızda kullanabilirsiniz.

test: 
    stage: test 
    image: <your php-fpm image here> 
    script: 
    - cd /app 
    - composer install 
    - make runTests 
İlgili konular