5.验证一下,并用curl测试
[root@web1 docker]# docker run -d --name my_nginx1 zxg/nginx1 #后台运行整个容器751a8f9dda48c034d40b8855b3dd6c7aaf785eeaa9ae404c5eb3c0271e434f50[root@web1 docker]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES751a8f9dda48 zxg/nginx1 "nginx" About a minute ago Up About a minute 80/tcp my_nginx1[root@web1 docker]# docker exec -it my_nginx1 bash #进入容器[root@751a8f9dda48 /]# cat /usr/share/nginx/html/index.html #查看文件是否添加到容器this is docker-centos7-nginx1[root@751a8f9dda48 /]# cat /etc/nginx/nginx.conf # For more information on configuration, see:# * Official English Documentation: http://nginx.org/en/docs/# * Official Russian Documentation: http://nginx.org/ru/docs/user nginx;worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;# Load dynamic modules. See /usr/share/nginx/README.dynamic.include /usr/share/nginx/modules/*.conf;events { worker_connections 1024;}http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; 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; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }# Settings for a TLS enabled server.## server {# listen 443 ssl http2 default_server;# listen [::]:443 ssl http2 default_server;# server_name _;# root /usr/share/nginx/html;## ssl_certificate "/etc/pki/nginx/server.crt";# ssl_certificate_key "/etc/pki/nginx/private/server.key";# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 10m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;## # Load configuration files for the default server block.# include /etc/nginx/default.d/*.conf;## location / {# }## error_page 404 /404.html;# location = /40x.html {# }## error_page 500 502 503 504 /50x.html;# location = /50x.html {# }# }}daemon off;[root@751a8f9dda48 /]# exitexit[root@web1 docker]# [root@751a8f9dda48 html]# curl 127.0.0.1this is docker-centos7-nginx1[root@751a8f9dda48 html]#[root@web1 ~]# docker inspect my_nginx1 |grep IPAddress "SecondaryIPAddresses": null, "IPAddress": "172.17.0.2", "IPAddress": "172.17.0.2",[root@web1 ~]# curl 172.17.0.2this is docker-centos7-nginx1[root@web1 ~]#
【推荐docker file这种方法 Docker3-Dockerfile创建镜像的方法】
推荐阅读
- Dockerfile制作镜像精简之道
- 三款御用减肥茶推荐
- 安装docker-machine的两种方法
- 立春养生要养阳气 中医推荐三大法宝
- 立春吃什么养生 推荐八种最佳食物
- docker中的容器安装PHP扩展件
- 有什么推荐的男男泰剧 泰剧最火的男男剧2020大尺
- 使用docker配置域名跳转
- 夏季要健脾益气 推荐养脾三方法
- 夏季养生吃什么 养生药膳大推荐
