Skip to content

Instantly share code, notes, and snippets.

@dfang
Last active May 8, 2016 16:41
Show Gist options
  • Save dfang/b0af452d4202503b084594c77e924fa9 to your computer and use it in GitHub Desktop.
Save dfang/b0af452d4202503b084594c77e924fa9 to your computer and use it in GitHub Desktop.
Dockfile
```Dockerfile
FROM busybox
ARG EXPOSED_PORTS
ENV EXPOSED_PORTS ${EXPOSED_PORTS:-20000}
RUN echo ${EXPOSED_PORTS}
EXPOSE ${EXPOSED_PORTS}
```
这种写法也可以不传 --build-arg
docker build -t test .
docker build --build-arg EXPOSED_PORTS="10001 10002" -t test .
关键在于第三行
https://docs.docker.com/engine/reference/builder/#environment-replacement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment