CLI to manage arguments when building a image using docker.
217
Docker-build-yaml (dbyml) is a CLI tool to build a docker image with build options loaded from yaml. Instead of running the docker build with many options, write options in config file, build your docker image with them. It helps you to manage build process more readable and flexible.
To use dbyml, Docker Engine must be installed on host for build and run docker commands without root privileges (as non-root user) on client. Refer to Manage Docker as a non-root user or Docker rootless mode for non-root user setting.
To build your image from Dockerfile, you must make Dockerfile and config file where the build options to be passed to docker command are listed . For example, we will make the following Dockerfile and dbyml.yml in the same directory.
FROM alpine:latest
ARG key1
RUN echo "$key1" > arg.txt && \
cat arg.txt && \
rm arg.txt
# You can write any process
name is required.tag is optional. Default value is latest.ARG key1 in the Dockerfile, Set build_args field and key name and its value in config.---
image:
name: myimage
tag: v1.0
build_args:
key1: "This is set by dbyml."
Run dbyml to build the image from your Dockerfile.
$ dbyml
The image myimage:v1.0 will be created after successfully build.
If Dockerfile and config file are not in the same directory, you must set path to the Dockerfile with path field in the config.
---
image:
name: myimage
tag: v1.0
path: path/to/Dockerfile
To run dbyml in docker container, mount the followings paths on host to the container on build.
/var/run/docker.sock required to use the docker engine on host in a container.${PWD} A directory containing a Dockerfile and dbyml.yml must be mounted in container. See the example below.Generate a configuration file dbyml.yml.
$ docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${PWD}:/work \
docogawa/dbyml:latest --init -q
# Change owner if needed.
$ sudo chown ${USER}:${USER} dbyml.yml
Build a image from Dockerfile and dbyml.yml in the current directory.
# Check that Dockerfile and dbyml.yml exist.
$ ls -1 .
Dockerfile
dbyml.yml
# Build a image.
$ docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${PWD}:/work \
docogawa/dbyml:latest
See https://github.com/git-ogawa/dbyml for more details.
Content type
Image
Digest
sha256:b8e3ef2c9…
Size
56.1 MB
Last updated
over 3 years ago
docker pull docogawa/dbyml