Hi,
I have a Spring Boot Application, which I host in a local gitlab-ce Edition. By now, that works fine.
Now I like to use CI/CD to deploy it. It should be deployed at a first step to a local docker swarm for staging.
I’m using the following .gitlab-ci.yml:
image: docker:latest
services:
- docker:dind
variables:
SPRING_PROFILES_ACTIVE: gitlab-ci
stages:
- build
- package
- deploy
maven-build:
image: maven:3-jdk-8
stage: build
script: "mvn package -B"
artifacts:
paths:
- target/*.jar
docker-build:
stage: package
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN devel.local:4567
- docker build -t devel.local:4567/dp/service-discovery .
- docker push devel.local:4567/dp/service-discovery
deploy-to-swarm:
stage: deploy
variables:
DOCKER_HOST: tcp://devel.local:2375
SERVICE_NAME: service_discovery
image: docker:latest
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN devel.local:4567
- docker stack deploy --with-registry-auth --compose-file=docker-stack-compose.yml ${CI_PROJECT_NAMESPACE}-${CI_PROJECT_NAME}-${SERVICE_NAME}
environment:
name: master
url: http://devel.local
only:
- master
When running the pipe the stages build and package works fine. The docker Image is placed at the gitlab-ce Docker Registry.
But when running stage deploy I get the following error:
[0K] Running with gitlab-runner 10.6.0 (a3543a27)
[0K] on Standard Local Runner caf7b4c7
[0K] Using Docker executor with image docker:latest ...
[0K] Starting service docker:dind ...
[0K] Pulling docker image docker:dind ...
[0K] Using docker image sha256:6fc95ba0a7762a13d4db830df765c534ece1963f11093dfb8940f525b63084c3 for docker:dind ...
[0K] Waiting for services to be up and running...
[0K] Pulling docker image docker:latest ...
[0K] Using docker image sha256:41e946672182197f856cfbf3b1d536dc0a561eef8bceccb4828e28d0d194d772 for docker:latest ...
section_start:1524125021:prepare_script
[0K] Running on runner-caf7b4c7-project-1-concurrent-0 via v22018046075764345...
section_end:1524125022:prepare_script
[0K] section_start:1524125022:get_sources
[0K] Fetching changes...
Removing target/
HEAD is now at ea42740 Deployment
Checking out ea427405 as master...
Skipping Git submodules setup
section_end:1524125024:get_sources
[0K] section_start:1524125024:restore_cache
[0K] section_end:1524125026:restore_cache
[0K] section_start:1524125026:download_artifacts
[0K] Downloading artifacts for maven-build (56)...
Downloading artifacts from coordinator... ok id=56 responseStatus=200 OK token=yCsX7Bp-
section_end:1524125030:download_artifacts
[0K] section_start:1524125030:build_script
[0K] $ docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN devel.local:4567
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon at tcp://devel.local:2375. Is the docker daemon running?). Using system default: https://index.docker.io/v1/
Cannot connect to the Docker daemon at tcp://devel.local:2375. Is the docker daemon running?
section_end:1524125031:build_script
[0K] section_start:1524125031:after_script
[0K] section_end:1524125033:after_script
[0K] ERROR: Job failed: exit code 1
Is here something wrong in my configuration?
Best regards
Daniel