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

Ability to combine multiple commands in one RUN statement? #904

Closed
noah10 opened this issue Nov 4, 2016 · 1 comment
Closed

Ability to combine multiple commands in one RUN statement? #904

noah10 opened this issue Nov 4, 2016 · 1 comment

Comments

@noah10
Copy link

noah10 commented Nov 4, 2016

According to https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/ , one should always combine your apt-get update and apt-get install commands, e.g.

RUN apt-get update && apt-get install -y package-foo

Is there a way to do this when adding a run command? Not surprisingly,

ExecCmd("RUN", "apt-get", "update", "&&", "apt-get", "install", "-y", "package-foo")

...results in '&&' and subsequent items being treated as parameters for the apt-get binary, which obviously doesn't work.

@noah10
Copy link
Author

noah10 commented Nov 8, 2016

Figured it out: The trick is to use Cmd, not ExecCmd. Unlike ExecCmd, Cmd doesn't separate the binary and the parameters; it simply executes the entire thing as a single shell command. So if you add something like

Cmd("RUN", "apt-get update -y && apt-get install package-foo -y")

to your dockerCommands it will do what you want it to.

@noah10 noah10 closed this as completed Nov 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant