How do you enable BuildKit with docker-compose?

后端 未结 2 567
面向向阳花
面向向阳花 2021-02-05 02:57

I tried export DOCKER_BUILDKIT=1 before a docker-compose build command and I did not see the expected BuildKit output. What did I miss?

2条回答
  •  你的背包
    2021-02-05 03:38

    You can use this command to tell docker-compose to use the Docker CLI when executing a build.

    COMPOSE_DOCKER_CLI_BUILD=1 docker-compose build
    

    You should see the same build as usual, but with this warning:

    WARNING: Native build is an experimental feature and could change at any time

    And you can go like that to parametrize the CLI to use BuildKit instead of the default builder:

    COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose build
    

    Windows version:

    set "COMPOSE_DOCKER_CLI_BUILD=1" & set "DOCKER_BUILDKIT=1" & docker-compose build
    

    You can also enable BuildKit globally, editing /etc/docker/daemon.json file, adding:

    { "features": { "buildkit": true } }
    

    For more informations: https://docs.docker.com/develop/develop-images/build_enhancements/

提交回复
热议问题