A Docker image for building Docker images
1.8K
A Docker image for building Docker images
This Docker image requires a few volume mounts. First, the Docker socket must be mounted so that the Docker CLI in the container can talk to the daemon on the host. Second, the context of the Docker image being built should be mounted at /docker-context. Finally, if you'd like to push the images being built, mount credentials to do so at /root/.docker/config.json.
At runtime, set one or more commands on the container being started.
Dockerfile relative to the /docker-context volume.Build this image and tag it as dwolla/dwollaci-docker-build:new-build:
docker run \
-it \
--rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$PWD":/docker-context:ro \
dwolla/dwollaci-docker-build:latest \
Dockerfile \
dwolla/dwollaci-docker-build:new-build
This example will not push the built image because no credentials were mounted.
Build this image and push it using multiple tags using the current user's Docker credentials. (Assumes docker login has already been run)
docker run \
-it \
--rm \
-v "$HOME/.docker/config.json":/root/.docker/config.json:ro \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$PWD":/docker-context:ro \
dwolla/dwollaci-docker-build:latest \
Dockerfile \
dwolla/dwollaci-docker-build:tag1 \
dwolla/dwollaci-docker-build:tag2
If you have access to the Docker socket and and run docker run, why not just use docker build? Normally, you should do just that. Dwolla uses this image to simplify some Jenkins jobs where we need to build Docker images in a specific context.
Content type
Image
Digest
Size
16 MB
Last updated
over 4 years ago
docker pull dwolla/dwollaci-docker-build