docker_practice/image/dockerfile/env.md

36 lines
1.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### ENV
* `ENV <key> <value>`
* `ENV <key1>=<value1> <key2>=<value2>...`
`RUN`使
```Dockerfie
ENV VERSION=1.0 DEBUG=on \
NAME="Happy Feet"
```
Shell
使 `node` `Dockerfile`
```docker
ENV NODE_VERSION 7.2.0
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
&& curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \
&& rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
```
`NODE_VERSION` `RUN` 使 `$NODE_VERSION` `7.2.0` `Dockerfile`
`ADD``COPY``ENV``EXPOSE``FROM``LABEL``USER``WORKDIR``VOLUME``STOPSIGNAL``ONBUILD``RUN`
使 `Dockerfile` 使