在docker-compose build
Dockerfile被其中的西里尔符号截断了。
例如,如果我在Dockerfile中得到7个西里尔符号,那么文件末尾的最后7个符号将被“切断”。
docker-compose version
docker-compose version 1.25.0, build unknown
docker-py version: 4.1.0
CPython version: 3.8.1
OpenSSL version: OpenSSL 1.1.1d 10 Sep 2019
docker version
Client:
Version: 19.03.5-ce
API version: 1.40
Go version: go1.13.4
Git commit: 633a0ea838
Built: Fri Nov 15 03:19:09 2019
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 19.03.5-ce
API version: 1.40 (minimum version 1.12)
Go version: go1.13.4
Git commit: 633a0ea838
Built: Fri Nov 15 03:17:51 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.3.2.m
GitCommit: d50db0a42053864a270f648048f9a8b4f24eced3.m
runc:
Version: 1.0.0-rc9
GitCommit: d736ef14f0288d6993a1845745d6756cfc9ddd5a
docker-init:
Version: 0.18.0
GitCommit: fec3683
docker-compose config
see in the "steps to reproduce"
创建context
(空)目录, docker-compose.yml
和Dockerfile
version: '3.7'
services:
test-pass:
build:
context: .
dockerfile: Dockerfile
test-fail:
build:
context: context
# path relative to the context
dockerfile: ../Dockerfile
FROM alpine
# шшш и ффф
RUN touch test
运行docker-compose build test-fail
docker-compose build test-fail
Building test-fail
Step 1/2 : FROM alpine
---> cdf98d1859c1
Step 2/2 : RUN touc
---> Running in fc83cc1f2b69
/bin/sh: touc: not found
ERROR: Service 'test-fail' failed to build: The command '/bin/sh -c touc' returned a non-zero code: 127
字符串h test\n
(7个符号)消失了。
如果Dockerfile位于上下文文件夹中,则不会出现此问题(请查看测试通过服务)。
通过使用docker build
不会出现此问题。
预期结果是成功创建的图像,例如通过使用docker build
:
docker build -f Dockerfile context
Sending build context to Docker daemon 1.583kB
Step 1/2 : FROM alpine
---> cdf98d1859c1
Step 2/2 : RUN touch test
---> Using cache
---> bb6362bff392
Successfully built bb6362bff392
N/A
感谢您报告此问题并提供清晰的复制样本,并对破损情况进行了初步调查。 下周我将调查这个问题
解决方法是,您可以通过设置COMPOSE_DOCKER_CLI_BUILD=true
来启用本机CLI构建器(我希望在将来的版本中将其作为默认值)
问题(临时)是由https://github.com/docker/docker-py/blob/master/docker/utils/build.py#L107 -L109引起的
tar大小以len(contents)
==字符数计算,而实际的tar条目由contents.encode('utf-8')
,由于某些字符将被编码为N> 1个字节,因此它将被截断。