Amir
Amir

Reputation: 1979

Issue with build and deploy while using local bitbucket runner

I am using bitbucket as repository. I created a docker file and I setup a runner to execute things on my machine.

The issue is that when I want to run the docker build command, I am getting below error:

+ docker build -t my_app .
failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial tcp 127.0.0.1:2375: connect: connection refused

here is my pipeline file:

# definitions:
#    services:
#       docker:
#          image: docker:dind

# options:
#   docker: true

pipelines:
  default:
      - step:
          runs-on:
            - self.hosted
            - linux.shell
          # services:
          #   - docker
          script:
            - echo $HOSTNAME
            - export DOCKER_BUILDKIT=1
            - docker build -t my_app .

I tried to use :

 definitions:
    services:
       docker:
          image: docker:find

But I was getting this error: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

I tried to add

 services:
   - docker

But again no luck...

Would you mind help me how setup/build my docker file when I have a local PC runner? is it possible at all?

Upvotes: 0

Views: 964

Answers (1)

Amir
Amir

Reputation: 1979

I solved my problem by changing my runner type from linux.shell to linux docker and my pipeline also changed accordingly:

definitions:
   services:
      docker:
         image: docker:dind

pipelines:
  default:
      - step:
          runs-on:
            - self.hosted
            - linux
          services:
            - docker
          script:
            - echo $HOSTNAME
            - docker version
            - docker build -t my_app .

Upvotes: 0

Related Questions