Docker使用---静态网站测试
来源:互联网 发布:绿盟网络审计系统 编辑:程序博客网 时间:2024/06/05 10:53
Dockerfile
#为Nginx Dockerfile创建一个目录$ mkdir sample$ cd sample$ touch Dockerfile#获取Nginx配置文件$ cd sample$ mkdir nginx && cd nginx$ wget https://raw.githubusercontent.com/jamtur01/dockerbook-code/master/code/5/sample/nginx/global.conf$ wget https://raw.githubusercontent.com/jamtur01/dockerbook-code/master/code/5/sample/nginx/nginx.conf$ cd ..FROM ubuntu:14.04MAINTAINER juedaiyuer "juedaiyuer@gmail.com"ENV REFRESHED_AT 2016-7-10RUN apt-get updateRUN apt-get -y -q install nginxRUN mkdir -p /var/www/htmlADD nginx/global.conf /etc/nginx/conf.d/ADD nginx/nginx.conf /etc/nginx/nginx.confEXPOSE 80#global.confserver { listen 0.0.0.0:80; server_name _; root /var/www/html/website; index index.html index.htm; access_log /var/log/nginx/default_access.log; error_log /var/log/nginx/default_error.log;}#nginx.conf#阻止nginx进入后台,强制其在前台运行;保持Docker容器的活跃状态,其中运行的进程不能中断user www-data;worker_processes 4;pid /run/nginx.pid;daemon off;events { }http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; gzip on; gzip_disable "msie6"; include /etc/nginx/conf.d/*.conf;}#构建镜像$ sudo docker build -t juedaiyuer/nginx .
创建网站
#在sample目录下的操作$ mkdir website && cd website$ wget https://github.com/jamtur01/dockerbook-code/blob/master/code/5/sample/website/index.html$ cd ..# -v 允许我们将宿主机的目录作为卷,挂载到容器里$ sudo docker run -d -p 80 --name website -v $PWD/website:/var/www/html/website juedaiyuer/nginx nginx$ sudo docker ps -lCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESb46432754bc4 juedaiyuer/nginx "nginx" 19 seconds ago Up 18 seconds 0.0.0.0:32768->80/tcp websitehttp://localhost:32768
可以随时对index文件进行修改
卷
不想把应用或者代码构建到镜像中时,卷的价值得到体现
- 希望同时对代码做开发和测试
- 代码改动很频繁,不想在开发过程中重构镜像
- 希望在多个容器间共享代码
0 0
- Docker使用---静态网站测试
- Docker nginx 静态网站
- 在docker 上使用alpine linux建立简易静态网站
- 命令部署一个docker静态网站
- 5.Ubuntu16.04Docker部署nginx实现静态网站
- 在centos docker中利用nginx部署静态网站
- 使用kekyll构建静态网站
- 静态测试工具pclint使用
- 使用 Docker 构建开发、测试环境
- 如何使用Rally+Docker测试OpenStack
- 使用 Docker 构建开发、测试环境
- Docker的安装和测试使用
- 如何使用docker搭建oracle测试环境
- 5-在测试中使用Docker
- 使用siege测试网站性能
- 使用NetBox测试ASP网站
- 使用http_load网站压力测试
- 使用数据卷容器,配置Nginx Docker作为静态文件服务器
- 二分&三分
- 初识TCP/IP协议(TCP/IP系统学习(1))
- xcode配置绝对路径与相对路径
- 翻写Nehe的OpenGL教程
- 传球游戏_vijos1485_递推
- Docker使用---静态网站测试
- MQTT和spring的整合(生产者)
- POJ1088 高山滑雪【记忆化搜索】
- B. Mike and Shortcuts(cf#361)
- Unity android 接有米广告和分享功能
- 【Python学习笔记】python高级特性:列表生成式
- 一点感想
- 传球游戏/vijos1485/递推
- Nms