mirror of https://github.com/docker/cli.git
Rewrote the ENTRYPOINT section in builder
Docker-DCO-1.1-Signed-off-by: James Turnbull <james@lovedthanlost.net> (github: jamtur01)
This commit is contained in:
parent
1bb925be97
commit
7cf495874c
|
@ -374,41 +374,47 @@ The copy obeys the following rules:
|
||||||
ENTRYPOINT has two forms:
|
ENTRYPOINT has two forms:
|
||||||
|
|
||||||
- `ENTRYPOINT ["executable", "param1", "param2"]`
|
- `ENTRYPOINT ["executable", "param1", "param2"]`
|
||||||
(like an *exec*, preferred form)
|
(like an *exec*, the preferred form)
|
||||||
- `ENTRYPOINT command param1 param2`
|
- `ENTRYPOINT command param1 param2`
|
||||||
(as a *shell*)
|
(as a *shell*)
|
||||||
|
|
||||||
There can only be one `ENTRYPOINT` in a Dockerfile. If you have more than one
|
There can only be one `ENTRYPOINT` in a `Dockerfile`. If you have more
|
||||||
`ENTRYPOINT`, then only the last one in the Dockerfile will have an effect.
|
than one `ENTRYPOINT`, then only the last one in the `Dockerfile` will
|
||||||
|
have an effect.
|
||||||
|
|
||||||
An `ENTRYPOINT` helps you to configure a container that you can run as an
|
An `ENTRYPOINT` helps you to configure a container that you can run as
|
||||||
executable. That is, when you specify an `ENTRYPOINT`, then the whole container
|
an executable. That is, when you specify an `ENTRYPOINT`, then the whole
|
||||||
runs as if it was just that executable.
|
container runs as if it was just that executable.
|
||||||
|
|
||||||
The `ENTRYPOINT` instruction adds an entry command that will **not** be
|
Unlike the behavior of the `CMD` instruction, The `ENTRYPOINT`
|
||||||
overwritten when arguments are passed to `docker run`, unlike the behavior
|
instruction adds an entry command that will **not** be overwritten when
|
||||||
of `CMD`. This allows arguments to be passed to the entrypoint. i.e.
|
arguments are passed to `docker run`. This allows arguments to be passed
|
||||||
`docker run <image> -d` will pass the "-d" argument to the ENTRYPOINT.
|
to the entry point, i.e. `docker run <image> -d` will pass the `-d`
|
||||||
|
argument to the entry point.
|
||||||
|
|
||||||
You can specify parameters either in the ENTRYPOINT JSON array (as in
|
You can specify parameters either in the `ENTRYPOINT` JSON array (as in
|
||||||
"like an exec" above), or by using a CMD statement. Parameters in the
|
"like an exec" above), or by using a `CMD` instruction. Parameters in
|
||||||
ENTRYPOINT will not be overridden by the `docker run`
|
the `ENTRYPOINT` instruction will not be overridden by the `docker run`
|
||||||
arguments, but parameters specified via CMD will be overridden
|
arguments, but parameters specified via a `CMD` instruction will be
|
||||||
by `docker run` arguments.
|
overridden by `docker run` arguments.
|
||||||
|
|
||||||
Like a `CMD`, you can specify a plain string for the `ENTRYPOINT` and it will
|
Like a `CMD`, you can specify a plain string for the `ENTRYPOINT` and it
|
||||||
execute in `/bin/sh -c`:
|
will execute in `/bin/sh -c`:
|
||||||
|
|
||||||
FROM ubuntu
|
FROM ubuntu
|
||||||
ENTRYPOINT wc -l -
|
ENTRYPOINT ls -l
|
||||||
|
|
||||||
For example, that Dockerfile's image will *always* take STDIN as input
|
For example, that `Dockerfile`'s image will *always* take a directory as
|
||||||
("-") and print the number of lines ("-l"). If you wanted to make this
|
an input and return a directory listing. If you wanted to make this
|
||||||
optional but default, you could use a CMD:
|
optional but default, you could use a `CMD` instruction:
|
||||||
|
|
||||||
FROM ubuntu
|
FROM ubuntu
|
||||||
CMD ["-l", "-"]
|
CMD ["-l"]
|
||||||
ENTRYPOINT ["/usr/bin/wc"]
|
ENTRYPOINT ["/usr/bin/ls"]
|
||||||
|
|
||||||
|
> **Note**:
|
||||||
|
> It is preferable to use the JSON array format for specifying
|
||||||
|
> `ENTRYPOINT` instructions.
|
||||||
|
|
||||||
## VOLUME
|
## VOLUME
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue