I am using gitlab ci for continues integration, I want to run unit test on my code and then build a docker image and then deploy it. But the problem which I am facing is that how to run a docker service in gilab ci.
I get this error
"Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running"
after my docker build command is run. do I need to install docker in gitlab-ci?
This is my .gitlab-ci.yml file
image: node:latest
before_script:
stages:
- test
- production
- clean_up
services:
- docker:dind
test:
stage: test
script:
- npm install
- npm install -g swagger
- npm test
production:
type: deploy
stage: production
image: docker:latest
script:
- docker build -t testimage -t testimage:latest .
- docker tag testimage docker.abc.xyz.com/testimage
- docker push docker.abc.xyz.com/testimage
only:
- development
clean_up_job:
stage: clean_up
script:
- rm -rf node_modules
- npm uninstall -g swagger
when: on_failure
I am not using GitLab Runner at the moment.
Try putting services
inside production
job, like this:
production:
type: deploy
stage: production
image: docker:latest
services:
- docker:dind
script:
- docker build -t testimage -t testimage:latest .
- docker tag testimage docker.abc.xyz.com/testimage
- docker push docker.abc.xyz.com/testimage
only:
- development
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With