Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Facing error while building docker image in bitbucket pipeline

 

Please find the error below

error during connect: Get "http://docker:2375/v1.24/version": dial tcp: lookup docker on 10.32.0.10:53: no such host

1 answer

0 votes

Welcome to the Community!

That means what it says; nothing is responding to your call on the URL you have given it.  You'll need to change it to use the actual address of the host you're trying to reach.

Can you help me out in this? Actually we are trying to shift from Gitlab to Bitbucket.

I have created a runner on Google Kubernetes Engine. We use Google container registry as to save our docker images. I.m trying to setup a pipeline where my image gets build and pushed to google container registry.

This is my bitbucket-pipelines.yml file . Go through it might be you get some idea what I am trying to achieve.

 

definitions:
  services:
     docker:
      image: docker:20.10.7-dind
      variables:
        DOCKER_OPTS: "--mtu=1300"
        DOCKER_DRIVER: overlay2
        DOCKER_HOST: tcp://docker:2375
        DOCKER_TLS_CERTDIR: ""
       
pipelines:
  default:
      - step:
          name: publish
          image: docker:latest
          runs-on:
            - 'self.hosted'
            - 'linux'          
          script:
 #           - export IMAGE_NAME=asia.gcr.io/$GCLOUD_PROJECT/$BITBUCKET_REPO_SLUG:$BITBUCKET_COMMIT
 #           - export ENVIRONMENT=uat          
            - apk add --update make ca-certificates openssl build-base python3-dev python3 libffi-dev libressl-dev bash git gettext curl
            - update-ca-certificates
            - echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json
            - tar zxf google-cloud-sdk.tar.gz && ./google-cloud-sdk/install.sh --usage-reporting=false --path-update=true
            - google-cloud-sdk/bin/gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json
            - docker version
            - docker login -u _json_key --password-stdin https://asia.gcr.io < ${HOME}/gcloud-service-key.json
            - docker build -t $IMAGE_NAME .
            - docker tag $IMAGE_NAME "asia.gcr.io/$GCLOUD_PROJECT_ID/$IMAGE_NAME:$(echo $CI_COMMIT_SHA | cut -c1-8)"
            - docker push "asia.gcr.io/$GCLOUD_PROJECT_ID/$IMAGE_NAME:$(echo $CI_COMMIT_SHA | cut -c1-8)"
          services:
            - docker

      - step:
          name: Deploy
          image: google/cloud-sdk:alpine
          runs-on:
            - 'self.hosted'
            - 'linux'          
          script:
           - echo $GCLOUD_SERVICE_KEY_KUBE > ${HOME}/gcloud-service-key.json
           - gcloud components install kubectl
           - gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json  --project $GCLOUD_PROJECT_ID
           - gcloud container clusters get-credentials $CLUSTER_NAME --zone $CLUSTER_ZONE
           - kubectl -n $ENVIRONMENT set image deployment/$K8S_DEPLOYMENT $K8S_IMAGE=asia.gcr.io/$GCLOUD_PROJECT_ID/$IMAGE_NAME:$(echo $CI_COMMIT_SHA | cut -c1-8)
          services:
             - docker
           
options:
  docker: true

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,480 views 4 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you