Docker voor gevorderden
Mike Metzger
Data Engineering Consultant
linuxwindowsmacosx64_64 of amd64arm64arm7os/cpu, bijv. linux/amd64


--platform=$BUILDPLATFORM$BUILDPLATFORM is het platform van de host die de build draaitARG-directiveTARGETOS en TARGETARCHARG TARGETOS TARGETARCHenv definiëren.# Initial stage, using local platform FROM --platform=$BUILDPLATFORM golang:1.21 AS build# Copy source into place WORKDIR /src COPY . .# Pull the environment variables from the host ARG TARGETOS TARGETARCH# Compile code using the ARG variables RUN env GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /final/app .# Create container and load the cross-compiled code FROM alpine COPY --from=build /final/app /bin
docker buildx met opties, niet docker builddocker buildx biedt extra commando’s en functies t.o.v. docker build, zoals een platform opgevendocker buildx build --platform linux/amd64,linux/arm64 -t multi-platform-app .
docker buildx create --bootstrap --use.Docker voor gevorderden