Build with secret
- Dockerfile
# syntax = docker/dockerfile:1.6
FROM golang:1.21.1-alpine3.18
RUN --mount=type=secret,id=mysecret,target=/root/.ssh/id_rsa git clone git@gitlab.com:ricky/repo.git
- Command
export DOCKER_BUILDKIT=1
docker build --secret id=mysecret,src=id_rsa -t image .
Compose
# Force pull image
docker-compose up -d --pull always
Create buildx instance
# create buildx instance
docker buildx create --name builder --bootstrap --driver docker-container
# install emulators
docker run --privileged --rm tonistiigi/binfmt --install all
Create Network
docker network create -d bridge --subnet 172.100.0.0/24 --gateway 172.100.0.1 backend_dev
Multiple build-arg
docker build . -f ./scripts/Dockerfile \
--build-arg Date=$(date) \
--build-arg Tag=$(git rev-list -n 1 --tags) \
--build-arg Commit=$(git describe --tags --abbrev=0) \
-t ops-cli
Multiple platform
# create and use buildx instance
docker buildx create --use --name builder
# build multiple platform
docker buildx build --push --platform linux/arm64,linux/amd64 -t zeyanlin/ops-cli .
Run container in different platform
finch run -it --rm --platform=linux/arm64 zeyanlin/ops-cli /bin/sh