mirror of https://github.com/docker/cli.git
Merge pull request #2393 from thaJeztah/19.03_backport_codehints_compatibility
[19.03 backport] docs: update code-hints for compatibility with "rouge"
This commit is contained in:
commit
bf1f5fcfb3
|
@ -27,7 +27,7 @@ To learn more about Rexray: [https://github.com/codedellemc/rexray](https://gith
|
||||||
|
|
||||||
The following is the Dockerfile used to containerize rexray.
|
The following is the Dockerfile used to containerize rexray.
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
FROM debian:jessie
|
FROM debian:jessie
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends wget ca-certificates
|
RUN apt-get update && apt-get install -y --no-install-recommends wget ca-certificates
|
||||||
RUN wget https://dl.bintray.com/emccode/rexray/stable/0.6.4/rexray-Linux-x86_64-0.6.4.tar.gz -O rexray.tar.gz && tar -xvzf rexray.tar.gz -C /usr/bin && rm rexray.tar.gz
|
RUN wget https://dl.bintray.com/emccode/rexray/stable/0.6.4/rexray-Linux-x86_64-0.6.4.tar.gz -O rexray.tar.gz && tar -xvzf rexray.tar.gz -C /usr/bin && rm rexray.tar.gz
|
||||||
|
|
|
@ -146,7 +146,7 @@ builds [refer to the documentation in the BuildKit repository](https://github.co
|
||||||
|
|
||||||
Here is the format of the `Dockerfile`:
|
Here is the format of the `Dockerfile`:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
# Comment
|
# Comment
|
||||||
INSTRUCTION arguments
|
INSTRUCTION arguments
|
||||||
```
|
```
|
||||||
|
@ -167,7 +167,7 @@ Docker treats lines that *begin* with `#` as a comment, unless the line is
|
||||||
a valid [parser directive](#parser-directives). A `#` marker anywhere
|
a valid [parser directive](#parser-directives). A `#` marker anywhere
|
||||||
else in a line is treated as an argument. This allows statements like:
|
else in a line is treated as an argument. This allows statements like:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
# Comment
|
# Comment
|
||||||
RUN echo 'we are running some # of cool things'
|
RUN echo 'we are running some # of cool things'
|
||||||
```
|
```
|
||||||
|
@ -197,14 +197,14 @@ Due to these rules, the following examples are all invalid:
|
||||||
|
|
||||||
Invalid due to line continuation:
|
Invalid due to line continuation:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
# direc \
|
# direc \
|
||||||
tive=value
|
tive=value
|
||||||
```
|
```
|
||||||
|
|
||||||
Invalid due to appearing twice:
|
Invalid due to appearing twice:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
# directive=value1
|
# directive=value1
|
||||||
# directive=value2
|
# directive=value2
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ FROM ImageName
|
||||||
|
|
||||||
Treated as a comment due to appearing after a builder instruction:
|
Treated as a comment due to appearing after a builder instruction:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
FROM ImageName
|
FROM ImageName
|
||||||
# directive=value
|
# directive=value
|
||||||
```
|
```
|
||||||
|
@ -221,7 +221,7 @@ FROM ImageName
|
||||||
Treated as a comment due to appearing after a comment which is not a parser
|
Treated as a comment due to appearing after a comment which is not a parser
|
||||||
directive:
|
directive:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
# About my dockerfile
|
# About my dockerfile
|
||||||
# directive=value
|
# directive=value
|
||||||
FROM ImageName
|
FROM ImageName
|
||||||
|
@ -231,7 +231,7 @@ The unknown directive is treated as a comment due to not being recognized. In
|
||||||
addition, the known directive is treated as a comment due to appearing after
|
addition, the known directive is treated as a comment due to appearing after
|
||||||
a comment which is not a parser directive.
|
a comment which is not a parser directive.
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
# unknowndirective=value
|
# unknowndirective=value
|
||||||
# knowndirective=value
|
# knowndirective=value
|
||||||
```
|
```
|
||||||
|
@ -239,7 +239,7 @@ a comment which is not a parser directive.
|
||||||
Non line-breaking whitespace is permitted in a parser directive. Hence, the
|
Non line-breaking whitespace is permitted in a parser directive. Hence, the
|
||||||
following lines are all treated identically:
|
following lines are all treated identically:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
#directive=value
|
#directive=value
|
||||||
# directive =value
|
# directive =value
|
||||||
# directive= value
|
# directive= value
|
||||||
|
@ -334,7 +334,7 @@ handled as an instruction, cause it be treated as a line continuation. The resul
|
||||||
of this dockerfile is that second and third lines are considered a single
|
of this dockerfile is that second and third lines are considered a single
|
||||||
instruction:
|
instruction:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
FROM microsoft/nanoserver
|
FROM microsoft/nanoserver
|
||||||
COPY testfile.txt c:\\
|
COPY testfile.txt c:\\
|
||||||
RUN dir c:\
|
RUN dir c:\
|
||||||
|
@ -602,7 +602,7 @@ and use it to cross-compile to the target platform inside the stage.
|
||||||
`FROM` instructions support variables that are declared by any `ARG`
|
`FROM` instructions support variables that are declared by any `ARG`
|
||||||
instructions that occur before the first `FROM`.
|
instructions that occur before the first `FROM`.
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
ARG CODE_VERSION=latest
|
ARG CODE_VERSION=latest
|
||||||
FROM base:${CODE_VERSION}
|
FROM base:${CODE_VERSION}
|
||||||
CMD /code/run-app
|
CMD /code/run-app
|
||||||
|
@ -616,7 +616,7 @@ can't be used in any instruction after a `FROM`. To use the default value of
|
||||||
an `ARG` declared before the first `FROM` use an `ARG` instruction without
|
an `ARG` declared before the first `FROM` use an `ARG` instruction without
|
||||||
a value inside of a build stage:
|
a value inside of a build stage:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
ARG VERSION=latest
|
ARG VERSION=latest
|
||||||
FROM busybox:$VERSION
|
FROM busybox:$VERSION
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
|
@ -851,13 +851,13 @@ ports and map them to high-order ports.
|
||||||
|
|
||||||
By default, `EXPOSE` assumes TCP. You can also specify UDP:
|
By default, `EXPOSE` assumes TCP. You can also specify UDP:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
EXPOSE 80/udp
|
EXPOSE 80/udp
|
||||||
```
|
```
|
||||||
|
|
||||||
To expose on both TCP and UDP, include two lines:
|
To expose on both TCP and UDP, include two lines:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
EXPOSE 80/tcp
|
EXPOSE 80/tcp
|
||||||
EXPOSE 80/udp
|
EXPOSE 80/udp
|
||||||
```
|
```
|
||||||
|
@ -1491,7 +1491,7 @@ group (or GID) to use when running the image and for any `RUN`, `CMD` and
|
||||||
> On Windows, the user must be created first if it's not a built-in account.
|
> On Windows, the user must be created first if it's not a built-in account.
|
||||||
> This can be done with the `net user` command called as part of a Dockerfile.
|
> This can be done with the `net user` command called as part of a Dockerfile.
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
FROM microsoft/windowsservercore
|
FROM microsoft/windowsservercore
|
||||||
# Create Windows user in the container
|
# Create Windows user in the container
|
||||||
RUN net user /add patrick
|
RUN net user /add patrick
|
||||||
|
@ -1735,7 +1735,7 @@ these arguments inside the build stage redefine it without value.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
FROM alpine
|
FROM alpine
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
RUN echo "I'm building for $TARGETPLATFORM"
|
RUN echo "I'm building for $TARGETPLATFORM"
|
||||||
|
|
|
@ -487,7 +487,7 @@ When building a Dockerfile with multiple build stages, `--target` can be used to
|
||||||
specify an intermediate build stage by name as a final stage for the resulting
|
specify an intermediate build stage by name as a final stage for the resulting
|
||||||
image. Commands after the target stage will be skipped.
|
image. Commands after the target stage will be skipped.
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
FROM debian AS build-env
|
FROM debian AS build-env
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@ -555,7 +555,7 @@ desired files to a new scratch stage with [`COPY --from`](../builder.md#copy).
|
||||||
The example `Dockerfile` below uses a separate stage to collect the
|
The example `Dockerfile` below uses a separate stage to collect the
|
||||||
build-artifacts for exporting:
|
build-artifacts for exporting:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
FROM golang AS build-stage
|
FROM golang AS build-stage
|
||||||
RUN go get -u github.com/LK4D4/vndr
|
RUN go get -u github.com/LK4D4/vndr
|
||||||
|
|
||||||
|
@ -718,7 +718,7 @@ true
|
||||||
|
|
||||||
The following is an example of docker build with `--squash` argument
|
The following is an example of docker build with `--squash` argument
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
FROM busybox
|
FROM busybox
|
||||||
RUN echo hello > /hello
|
RUN echo hello > /hello
|
||||||
RUN echo world >> /hello
|
RUN echo world >> /hello
|
||||||
|
|
|
@ -167,7 +167,7 @@ Status: Downloaded newer image for ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25c
|
||||||
|
|
||||||
Digest can also be used in the `FROM` of a Dockerfile, for example:
|
Digest can also be used in the `FROM` of a Dockerfile, for example:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
FROM ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2
|
FROM ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2
|
||||||
MAINTAINER some maintainer <maintainer@example.com>
|
MAINTAINER some maintainer <maintainer@example.com>
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue