简体   繁体   English

使用本地 bitbucket runner 时构建和部署问题

[英]Issue with build and deploy while using local bitbucket runner

I am using bitbucket as repository.我正在使用 bitbucket 作为存储库。 I created a docker file and I setup a runner to execute things on my machine.我创建了一个 docker 文件并设置了一个运行器来在我的机器上执行。

The issue is that when I want to run the docker build command, I am getting below error:问题是当我想运行 docker build 命令时,出现以下错误:

+ 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.但我收到此错误:无法连接到位于 tcp://localhost:2375 的 Docker 守护程序。 Is the docker daemon running? docker 守护进程是否正在运行?

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?当我有本地 PC 运行器时,你介意帮我设置/构建我的 docker 文件吗? is it possible at all?有可能吗?

I solved my problem by changing my runner type from linux.shell to linux docker and my pipeline also changed accordingly:我通过将我的运行器类型从 linux.shell 更改为 linux docker 解决了我的问题,我的管道也相应地改变了:

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 .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM