louis kaisian
louis kaisian

Reputation: 11

How to connect to docker daemon using docker in docker without privilege mode

I'm new to BitBucket Piepline and trying to use it as GitLab Ci way.

Now I happen to face an issues where I was trying to build docker in docker container using dnd. error during connect: Post "http://docker:2375/v1.24/auth": dial tcp: lookup docker on 100.100.2.136:53: no such host

The above error show and I did some research believe was from the docker daemon. Yet the atlassin claim there were no intention to work on privilege mode thus I think of any other option.

bitbucker-pipelines.yml

definitions:
  services:
    docker: # can only be used with a self-hosted runner
      image: docker:23.0.0-dind

pipelines:
  default:
      - step:
          name: 'Login'
          runs-on: 
            - 'self.hosted'    
          services:
            - docker
          script:
            - echo $ACR_REGISTRY_PASSWORD | docker login -u $ACR_REGISTRY_USERNAME registry-intl.ap-southeast-1.aliyuncs.com --password-stdin 
      - step:
          name: 'Build'
          runs-on: 
            - 'self.hosted'
          services:
            - docker
          script:
            - docker build -t $ACR_REGISTRY:latest .
            - docker tag $(docker images | awk '{print $1}' | awk 'NR==2') $ACR_REGISTRY:$CI_PIPELINE_ID
            - docker push $ACR_REGISTRY:$CI_PIPELINE_ID      
      - step:

Dockerfile

FROM node:14.17.0

RUN mkdir /app

#working DIR 
WORKDIR /app 

# Copy Package Json File
COPY ["package.json","./"]

# Expose port 80
EXPOSE 80

# Install git
RUN npm install git

# Install Files
RUN npm install

# Copy the remaining sources code
COPY . .

# Run prisma db 
RUN npx prisma db pull

# Run prisma client
RUN npm i @prisma/client

# Build
RUN npm run build 

CMD [ "npm","run","dev","node","build/server.ts"]

Upvotes: 1

Views: 71

Answers (0)

Related Questions