How To Use Docker Buildx in Remote Docker?

For using Docker buildx, you need Docker version 19.03 & must enable the "Experimental features" option.

 

Below are the sample config and the build link for reference.

 

Build link: https://app.circleci.com/pipelines/github/pawanbahuguna/sample-config/43/workflows/f29ef170-b61b-412f-8b37-1f562cae7d7b/jobs/55

 

version: 2.1

workflows:
  build-deploy:
    jobs:
     - build

jobs:
  build:
    docker:
      - image: cimg/base:stable
    steps:
      - setup_remote_docker:
          version: 19.03.14
      - checkout
   - run: |
        ssh remote-docker \<<EOF
          sudo bash -c 'echo "{\"experimental\": true}" > /etc/docker/daemon.json'
          sudo systemctl restart docker
          sudo docker info
        EOF
   - run: |
          docker buildx build .     

 

If the above configuration is not working for your image, please try the below configuration:

 

version: 2.1

workflows:
  build-deploy:
    jobs:
     - build

jobs:
  build:
    docker:
      - image: cimg/base:stable
    steps:
      - setup_remote_docker:
          version: 19.03.14
      - checkout
      - run: |
          export DOCKER_CLI_EXPERIMENTAL=enabled
          docker buildx build .

 

References:

1. https://docs.docker.com/buildx/working-with-buildx/

2. https://circleci.com/docs/2.0/building-docker-images/#docker-version

 

Was this article helpful?
2 out of 2 found this helpful

Comments

0 comments

Article is closed for comments.