Skip to content

Docker in docker container with buildx built right in!

License

Notifications You must be signed in to change notification settings

maniator/dind-buildx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buildx in a docker container

docker image with buildx pre-installed

Can run all docker buildx commands easily in a docker container

docker run --rm \
    -e DOCKER_TLS_CERTDIR=/certs \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v $(pwd):$(pwd) -w $(pwd) maniator/dind-buildx build .

Which will build the Dockerfile in the current directory

Same with any docker buildx commands

If you want to share buildx configs/node creations between runs, you can hook a volume like this:

DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
BUILDX_DIR="$DOCKER_CONFIG/buildx"

mkdir -p $BUILDX_DIR

docker run --rm \
    -e DOCKER_TLS_CERTDIR=/certs \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v $BUILDX_DIR:/env_configs/.docker/buildx \
    -v $(pwd):$(pwd) -w $(pwd) maniator/dind-buildx \
    create --driver docker-container --name my_builder --use
docker run --rm \
    -e DOCKER_TLS_CERTDIR=/certs \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v $BUILDX_DIR:/env_configs/.docker/buildx \
    -v $(pwd):$(pwd) -w $(pwd) maniator/dind-buildx \
    --builder=my_builder build .

Docker

DockerHub Badge DockerHub Badge