-
Notifications
You must be signed in to change notification settings - Fork 0
dockerfile
KerwinKoo edited this page Dec 29, 2015
·
1 revision
docker build 时增加标签说明,而不是:
通过-t选项来docker build新的镜像以便于标记构建的镜像:
docker build -t="crosbymichael/sentry" --rm=true .
两个Docker的核心概念是可重复和可移植。
镜像应该可以运行在任何主机上并且运行尽可能多的次数。
在Dockerfile中你有能力映射私有和公有端口,但是你永远不要通过Dockerfile映射公有端口。
通过映射公有端口到主机上,你将只能运行一个容器化应用程序实例。(译者注:运行多个端口不就冲突啦)
#private and public mapping
EXPOSE 80:8080
#private only
EXPOSE 80
如果镜像的使用者关心容器公有映射了哪个公有端口,他们可以在运行镜像时通过-p参数设置,否则,Docker会自动为容器分配端口。
切勿在Dockerfile映射公有端口。
在本地测试时,可以将docker容器监听端口映射到外网端口,用于从浏览器中测试.
在Dockerfile中需要指定监听端口:
EXPOSE 8080
运行时通过-p参数指定映射及开启的端口
docker run -d -p 22 -p 8080:8080 [镜像名称]