在Ubuntu中Dcoker构建镜像
2017-07-01 15:56
330 查看
构建镜像
通过Dockerfile创建一个ubuntu带nginx的镜像
root@ubuntu:~# mkdir -p /dockerfile/df_test2 root@ubuntu:~# cd /dockerfile/df_test2/ root@ubuntu:/dockerfile/df_test2# vim Dockerfile root@ubuntu:/dockerfile/df_test2# cat Dockerfile # 设置基本的镜像,后续命令都以这个镜像为基础 FROM ubuntu # 作者信息 MAINTAINER shangwu # RUN命令会在上面指定的镜像里执行任何命令 RUN apt-get update RUN apt-get install -y nginx #暴露ssh端口 EXPOSE 80 root@ubuntu:/dockerfile/df_test2# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu-nginx v1 8377a82bd88d 6 minutes ago 232.8 MB ubuntu latest dc8dd8718e57 10 days ago 119.2 MB
执行Dockerfile
root@ubuntu:/dockerfile/df_test2# docker build -t='ubuntu-nginx-df_test2' . root@ubuntu:/dockerfile/df_test2# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu-nginx-df_test2 latest 266559c6bc7f 2 minutes ago 214.3 MB ubuntu-nginx v1 8377a82bd88d 13 minutes ago 232.8 MB ubuntu latest dc8dd8718e57 10 days ago 119.2 MB root@ubuntu:/dockerfile/df_test2#
通过刚刚创建的进行启动一个容器=nginx-web3
root@ubuntu:/dockerfile/df_test2# docker run -d --name=nginx-web3 -p 80 ubuntu-nginx-df_test2 nginx -g "daemon off;" ffd39288dbdcd6af18beba89278e80e88d464e9e34388c4d61f181dfe3081d1c root@ubuntu:/dockerfile/df_test2# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ffd39288dbdc ubuntu-nginx-df_test2:latest "nginx -g 'daemon of 7 seconds ago Up 6 seconds 0.0.0.0:32771->80/tcp nginx-web3 892ba90fd7f0 ubuntu-nginx:v1 "nginx -g 'daemon of 12 minutes ago Up 12 minutes 0.0.0.0:32770->80/tcp nginx-web2 fbfacadb6dfe ubuntu-nginx:v1 "nginx -g 'daemon of 13 minutes ago Up 13 minutes 80/tcp nginx-web1 666dc69dc786 ubuntu:latest "/bin/bash" 8 hours ago Up About an hour 0.0.0.0:32769->80/tcp web root@ubuntu:/dockerfile/df_test2# curl http://127.0.0.1:32771 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html> root@ubuntu:/dockerfile/df_test2#
相关文章推荐
- 在ubuntu14.04上构建docker私有镜像库
- CentOS7服务器Docker构建ubuntu镜像出错invalid argument
- 脉冲云[编译构建]服务----使用Dockerfile文件,在线构建Dcoker镜像
- 用dockerfile构建基于ubuntu的lnmp环境的镜像
- 基于Ubuntu 14.04构建mysql5.6 Docker镜像
- Dockerfile实战:构建基础的ubuntu14.04镜像
- (一)构建基于ubuntu docker MySQL 5.6 镜像并推送到Docker Hub
- SQL Server 2005 镜像构建手册
- GeekOS: 一、构建基于Ubuntu9.04的实验环境
- ubuntu挂在镜像文件
- Ubuntu下构建gstreamer开发环境
- 在Ubuntu下制作ISO镜像的方法
- Ubuntu 8.10 正式版下载地址[ISO]镜像
- Ubuntu下构建gstreamer开发环境
- [原]在ubuntu中构建.net开发环境(mono2.4+monodevelop2.0)(一)
- lzg_ad:构建通用版本的XPE\WES镜像文件 推荐
- Ubuntu下构建gstreamer开发环境
- 在ubuntu 8.04上构建openmoko qemu
- Ubuntu安装时候“正在扫描镜像站点”问题解决.