Now you have to make builder with explicit platforms
in docker buildx create command
docker buildx create --use --platform=linux/arm64,linux/amd64 --name multi-platform-builder
docker buildx inspect --bootstrap
docker buildx build --platform=linux/arm64,linux/amd64 --push --tag project-name:latest -f ./project-name/Dockerfile .
docker buildx create --use --platform=linux/arm64,linux/amd64 --name multi-platform-builder -
This command creates a new builder instance. In this case, it supports both linux/arm64 and linux/amd64 platforms. The --name flag sets a name for the builder- "multi-platform-builder".
docker buildx inspect --bootstrap
This command inspects the builder created in the previous step and performs any necessary setup or configuration. The --bootstrap flag indicates that the builder should be initialized if it hasn't been already
docker buildx build --platform=linux/arm64,linux/amd64 --push --tag project-name:latest -f ./project-name/Dockerfile .
This command builds a Docker image using the builder created earlier.
- The
--platform flag specifies the platforms for which the image should be built, similar to the first command.
- The
--push flag indicates that the built image should be pushed to a container registry.
- The --tag flag sets a tag for the image, in this case, "project-name:latest".
- The
-f flag specifies the path to the Dockerfile used for building the image, in this case, "./project-name/Dockerfile".
- The final "." represents the build context, which is the directory containing the files to be added to the image.