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 RUN don't support multiple lines #29170

Closed
rupertqin opened this issue Dec 6, 2016 · 11 comments · Fixed by #30010
Closed

Dockerfile RUN don't support multiple lines #29170

rupertqin opened this issue Dec 6, 2016 · 11 comments · Fixed by #30010

Comments

@rupertqin
Copy link


Dockerfile RUN don't support multiple lines

ENV: Mac OS
Docker Version: 1.13.0

RUN apt-get update && apt-get upgrade -y \
    && apt-get install -y curl wget git make sudo \
    && wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb \
    && dpkg -i erlang-solutions_1.0_all.deb \
    && apt-get update \
    && rm erlang-solutions_1.0_all.deb \

A Dockerfile RUN command contain multiple lines as above, when I build an image, an error jump out:

rupert in ~/Code/test/docker-phoenix λ docker build   .
Sending build context to Docker daemon 4.096 kB
Error response from daemon: Unknown instruction: &&

Then I switched docker version to 1.12.3, it work well.

Output of docker version:

Client:
 Version:      1.13.0-rc2
 API version:  1.25
 Go version:   go1.6.3
 Git commit:   1f9b3ef
 Built:        Wed Nov 23 06:24:33 2016
 OS/Arch:      darwin/amd64

Server:
 Version:             1.13.0-rc2
 API version:         1.25
 Go version:          go1.6.3
 Git commit:          1f9b3ef
 Built:               Wed Nov 23 06:24:33 2016
 OS/Arch:             darwin/amd64

Output of docker info:

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 6
Server Version: 1.13.0-rc2
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 6
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.27-moby
Operating System: Alpine Linux v3.4
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.951 GiB
Name: moby
ID: FH53:CQG6:5IWC:OMT3:KF47:BTEN:5NJO:D26M:PRXA:52PB:H2QH:XARU
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 16
 Goroutines: 31
 System Time: 2016-12-06T09:15:58.524022168Z
 EventsListeners: 2
Username: rupertqin
Registry: https://index.docker.io/v1/
WARNING: No kernel memory limit support
Insecure Registries:
 127.0.0.0/8
@thaJeztah
Copy link
Member

I suspect you have a blank line in your RUN instruction. 1.13.0-rc2 contained a bugfix to prevent the Dockerfile parser from continuing parsing lines as part of the previousRUNStatement. However, people have started to rely on this bug, so we reverted that change for 1.13 (see #29005)

docker 1.13.0-rc3 has been released, and a new beta will be released soon; however, you should be able to fix this by removing the blank line.

@JamesNyamu
Copy link

Try using

RUN apt-get update && apt-get upgrade -y;`
apt-get install -y curl wget git make sudo;`
wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb;`
dpkg -i erlang-solutions_1.0_all.deb;`
apt-get update;`
rm erlang-solutions_1.0_all.deb;`

@thaJeztah
Copy link
Member

@JamesNyamu that will only work if a custom escape character is set. If the issue is occurring on 1.13.0-rc2, but not on 1.12, it's most likely due to #29005, and fixed in 1.13.0-rc3

@justincormack
Copy link
Contributor

Have you got a space after any of the \? This is not correct, although I think we might have reverted the change, but it is not correct to have spaces after the continuation character.

@rupertqin
Copy link
Author

@justincormack I got no space after \, but some space before &&

@lombardoja
Copy link

Also make sure you have no line comments inside the RUN statements

@cirocosta
Copy link
Contributor

cirocosta commented Dec 16, 2016

Running Server Version: 1.13.0-rc3 if i have a trailing whitespace on ENV it fails.

For instance:

ciro@host02-dev:/tmp/teste$ docker build -t teste .
Sending build context to Docker daemon 2.048 kB
Error response from daemon: Unknown instruction: TEST2=ABC

ciro@host02-dev:/tmp/teste$ cat Dockerfile 
FROM alpine

ENV test=abc \ 
    test2=abc

(whitespace after \)

@thaJeztah
Copy link
Member

The change in behavior w.r.t. having trailing whitespace after a continuation-character looks to be because of #27146, which fixes the validation for this, so

/cc @duglin

@duglin
Copy link
Contributor

duglin commented Dec 27, 2016

right, this was basically a bug before - trailing whitespace after a \ should invalidate the semantics of \ being a continuation char.

@justincormack
Copy link
Contributor

@rupertqin can you upload your Dockerfile somewhere (not via cut and paste)? It looks like you must have a space after the \ which is invalid but used to work. But if it is not that we need to test it. I just tested DOS line endings and they dont seem to be an issue.

@thaJeztah
Copy link
Member

This should be fixed in 1.13.0-rc6. We reverted this change for now, so that we can work on a deprecation period (i.e., warn if a Dockerfile contains trailing whitespace), see #30010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants