Add more commands in creating an image

pull/1/head
Baohua Yang 2014-09-14 13:57:19 +08:00
parent 743a09086a
commit 68e02605f6
1 changed files with 11 additions and 0 deletions

View File

@ -104,6 +104,17 @@ Successfully built 324104cde6ad
*注意一个image不能超过127层
此外还可以利用ADD命令复制本地文件到镜像用EXPOSE命令来向外部开放端口用CMD命令来描述容器启动后运行的程序等。例如
```
# put my local web site in myApp folder to /var/www
ADD myApp /var/www
# expose mysqld port
EXPOSE 80
# the command to run
CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]
```
现在可以利用新创建的images来启动一个容器。
```
$ sudo docker run -t -i ouruser/sinatra:v2 /bin/bash