docker_practice/image/dockerfile/env.md

36 lines
1.9 KiB
Go
Raw Normal View History

### ENV
* `ENV <key> <value>`
* `ENV <key1>=<value1> <key2>=<value2>...`
2017-03-02 19:58:32 +08:00
`RUN`使
```Dockerfie
ENV VERSION=1.0 DEBUG=on \
NAME="Happy Feet"
```
Shell
使 `node` `Dockerfile`
```Dockerfile
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``LABEL``USER``WORKDIR``VOLUME``STOPSIGNAL``ONBUILD`
使 `Dockerfile` 使