Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile become truncated in certain circumstances #7112

Closed
Ovsyanka opened this issue Dec 31, 2019 · 5 comments
Closed

Dockerfile become truncated in certain circumstances #7112

Ovsyanka opened this issue Dec 31, 2019 · 5 comments

Comments

@Ovsyanka
Copy link

Description of the issue

conditions

  1. Dockerfile out of the context directory
  2. Dockerfile has cyrillic symbols (or other non-latin symbols I suppose)

result:

On docker-compose build Dockerfile truncated by amount of cyrillic symbols in it.

For example, if I got 7 cyrillic symbols in the Dockerfile last 7 symbols of the end of file become "cutted off".

Context information (for bug reports)

Output of 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

Output of 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

Output of docker-compose config

see in the "steps to reproduce"

Steps to reproduce the issue

Create context (empty) directory, docker-compose.yml and Dockerfile

docker-compose.yml

version: '3.7'

services:
  test-pass:
    build:
      context: .
      dockerfile: Dockerfile
  test-fail:
    build:
      context: context
      # path relative to the context
      dockerfile: ../Dockerfile

Dockerfile

FROM alpine

# шшш и ффф

RUN touch test

Run docker-compose build test-fail

Observed result

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

The string h test\n (7 symbols) was disappeared.

This problem doesn't appear if the Dockerfile is in the context folder (look at the test-pass service).

This problem doesn't appear by using docker build.

Expected result

Expected result is succesfully created image, like by using 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

Stacktrace / full error message

N/A
@ndeloof ndeloof self-assigned this Jan 3, 2020
@ndeloof
Copy link
Contributor

ndeloof commented Jan 3, 2020

thanks for reporting this issue with clear reproduction sample and initial investigation on breaking conditions. I'll investigate this issue next week

@ndeloof
Copy link
Contributor

ndeloof commented Jan 6, 2020

As a workaround, you can enable native CLI builder by setting COMPOSE_DOCKER_CLI_BUILD=true (I expect this to become default value in a future release)

@ndeloof
Copy link
Contributor

ndeloof commented Jan 6, 2020

issue (afaict) is caused by https://github.com/docker/docker-py/blob/master/docker/utils/build.py#L107-L109

tar size is computed as len(contents) == character counts, while the actual tar entry is set by contents.encode('utf-8'), which will then be truncated as some characters will be encoded on N>1 bytes.

ndeloof added a commit to ndeloof/docker-py that referenced this issue Jan 6, 2020
Close docker/compose#7112

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
ndeloof added a commit to ndeloof/docker-py that referenced this issue Jan 27, 2020
Close docker/compose#7112

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof ndeloof removed their assignment Sep 30, 2021
@stale
Copy link

stale bot commented Mar 30, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 30, 2022
@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically closed because it had not recent activity during the stale period.

@stale stale bot closed this as completed Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants