使用 docker python 库,
UID = USER_ID = os.getuid()
GROUP_ID = os.getgid()
USER = getpass.getuser()
HOME = "~"
DIR = os.getcwd()
DOCKER_GID = execute_shell_command('"$(stat -c "%g" /var/run/docker.sock)"', log_path)
VERSION = "latest"
BASE_DOCKER = "ubuntu:20.04"
assert os.path.isfile(dockerfile_path)
build_args = {
"UID": UID,
"DOCKER_GID": DOCKER_GID,
"UNAME": USER,
"VER": VERSION,
"BASE_IMAGE": BASE_DOCKER,
}
client = client = docker.from_env()
client.images.build(fileobj=dockerfile, buildargs=build_args)
得到
Bad Request ("error reading build args: json: cannot unmarshal number into Go value of type string")