Docker部署Nginx应用(2)
Docker部署Nginx应用(2)
1、拉取Nginx镜像
- [root@localhost ~]# docker pull nginx
- Using default tag: latest
- latest: Pulling from library/nginx
- f7e2b70d04ae: Pull complete
- 08dd01e3f3ac: Pull complete
- d9ef3a1eb792: Pull complete
- Digest: sha256:98efe605f61725fd817ea69521b0eeb32bef007af0e3d0aeb6258c6e6fe7fc1a
- Status: Downloaded newer image for nginx:latest
2、查看拉取到的镜像
- [root@localhost ~]# docker images
- REPOSITORY TAG IMAGE ID CREATED SIZE
- nginx latest 881bd08c0b08 days ago 109MB
3、在Docker中启用Nginx
- [root@localhost ~]# docker run -p : --name myNginx -d nginx
- ad7cc45c81ffadbd44254c1c043e048c677a4ebcd4ca618efcd098729cec2fa5
4、查看启动的nginx进程
- [root@localhost ~]# ps -ef|grep nginx
- root : ? :: nginx: master process nginx -g daemon off;
- : ? :: nginx: worker process
- root : pts/ :: grep --color=auto nginx
5、访问nginx
- [root@localhost ~]# curl http://localhost:80/
- <!DOCTYPE html>
- <html>
- <head>
- <title>Welcome to nginx!</title>
- <style>
- body {
- width: 35em;
- margin: 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>
6、监测Nginx引用状态
- [root@localhost ~]# docker inspect ad7cc45c81ffadbd44254c1c043e048c677a4ebcd4ca618efcd098729cec2fa5
- [
- {
- "Id": "ad7cc45c81ffadbd44254c1c043e048c677a4ebcd4ca618efcd098729cec2fa5",
- "Created": "2019-03-12T09:58:06.595522099Z",
- "Path": "nginx",
- "Args": [
- "-g",
- "daemon off;"
- ],
- "State": {
- "Status": "running",
- "Running": true,
- "Paused": false,
- "Restarting": false,
- "OOMKilled": false,
- "Dead": false,
- "Pid": ,
- "ExitCode": ,
- "Error": "",
- "StartedAt": "2019-03-12T09:58:07.12571162Z",
- "FinishedAt": "0001-01-01T00:00:00Z"
- },
- "Image": "sha256:881bd08c0b08234bd19136957f15e4301097f4646c1e700f7fea26e41fc40069",
- "ResolvConfPath": "/var/lib/docker/containers/ad7cc45c81ffadbd44254c1c043e048c677a4ebcd4ca618efcd098729cec2fa5/resolv.conf",
- "HostnamePath": "/var/lib/docker/containers/ad7cc45c81ffadbd44254c1c043e048c677a4ebcd4ca618efcd098729cec2fa5/hostname",
- "HostsPath": "/var/lib/docker/containers/ad7cc45c81ffadbd44254c1c043e048c677a4ebcd4ca618efcd098729cec2fa5/hosts",
- "LogPath": "/var/lib/docker/containers/ad7cc45c81ffadbd44254c1c043e048c677a4ebcd4ca618efcd098729cec2fa5/ad7cc45c81ffadbd44254c1c043e048c677a4ebcd4ca618efcd098729cec2fa5-json.log",
- "Name": "/myNginx",
- "RestartCount": ,
- "Driver": "overlay2",
- "Platform": "linux",
- "MountLabel": "",
- "ProcessLabel": "",
- "AppArmorProfile": "",
- "ExecIDs": null,
- "HostConfig": {
- "Binds": null,
- "ContainerIDFile": "",
- "LogConfig": {
- "Type": "json-file",
- "Config": {}
- },
- "NetworkMode": "default",
- "PortBindings": {
- "80/tcp": [
- {
- "HostIp": "",
- "HostPort": ""
- }
- ]
- },
- "RestartPolicy": {
- "Name": "no",
- "MaximumRetryCount":
- },
- "AutoRemove": false,
- "VolumeDriver": "",
- "VolumesFrom": null,
- "CapAdd": null,
- "CapDrop": null,
- "Dns": [],
- "DnsOptions": [],
- "DnsSearch": [],
- "ExtraHosts": null,
- "GroupAdd": null,
- "IpcMode": "shareable",
- "Cgroup": "",
- "Links": null,
- "OomScoreAdj": ,
- "PidMode": "",
- "Privileged": false,
- "PublishAllPorts": false,
- "ReadonlyRootfs": false,
- "SecurityOpt": null,
- "UTSMode": "",
- "UsernsMode": "",
- "ShmSize": ,
- "Runtime": "runc",
- "ConsoleSize": [
- ,
- ],
- "Isolation": "",
- "CpuShares": ,
- "Memory": ,
- "NanoCpus": ,
- "CgroupParent": "",
- "BlkioWeight": ,
- "BlkioWeightDevice": [],
- "BlkioDeviceReadBps": null,
- "BlkioDeviceWriteBps": null,
- "BlkioDeviceReadIOps": null,
- "BlkioDeviceWriteIOps": null,
- "CpuPeriod": ,
- "CpuQuota": ,
- "CpuRealtimePeriod": ,
- "CpuRealtimeRuntime": ,
- "CpusetCpus": "",
- "CpusetMems": "",
- "Devices": [],
- "DeviceCgroupRules": null,
- "DiskQuota": ,
- "KernelMemory": ,
- "MemoryReservation": ,
- "MemorySwap": ,
- "MemorySwappiness": null,
- "OomKillDisable": false,
- "PidsLimit": ,
- "Ulimits": null,
- "CpuCount": ,
- "CpuPercent": ,
- "IOMaximumIOps": ,
- "IOMaximumBandwidth": ,
- "MaskedPaths": [
- "/proc/asound",
- "/proc/acpi",
- "/proc/kcore",
- "/proc/keys",
- "/proc/latency_stats",
- "/proc/timer_list",
- "/proc/timer_stats",
- "/proc/sched_debug",
- "/proc/scsi",
- "/sys/firmware"
- ],
- "ReadonlyPaths": [
- "/proc/bus",
- "/proc/fs",
- "/proc/irq",
- "/proc/sys",
- "/proc/sysrq-trigger"
- ]
- },
- "GraphDriver": {
- "Data": {
- "LowerDir": "/var/lib/docker/overlay2/bc9ef8c119903b79ec581081d835c447ce00b72eb70b07b45d14b3dde7a37c51-init/diff:/var/lib/docker/overlay2/2f3362aabe1d926214bed5c53a425fde596d23861cc6a59168c594974623876a/diff:/var/lib/docker/overlay2/56da5031c7fb61e617765323e953cd71e07679f202f56df818342500f409b50b/diff:/var/lib/docker/overlay2/1321013bc28d4931f52ab6cc47de24b57c6221686aa25c1acea18c7f87131070/diff",
- "MergedDir": "/var/lib/docker/overlay2/bc9ef8c119903b79ec581081d835c447ce00b72eb70b07b45d14b3dde7a37c51/merged",
- "UpperDir": "/var/lib/docker/overlay2/bc9ef8c119903b79ec581081d835c447ce00b72eb70b07b45d14b3dde7a37c51/diff",
- "WorkDir": "/var/lib/docker/overlay2/bc9ef8c119903b79ec581081d835c447ce00b72eb70b07b45d14b3dde7a37c51/work"
- },
- "Name": "overlay2"
- },
- "Mounts": [],
- "Config": {
- "Hostname": "ad7cc45c81ff",
- "Domainname": "",
- "User": "",
- "AttachStdin": false,
- "AttachStdout": false,
- "AttachStderr": false,
- "ExposedPorts": {
- "80/tcp": {}
- },
- "Tty": false,
- "OpenStdin": false,
- "StdinOnce": false,
- "Env": [
- "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
- "NGINX_VERSION=1.15.9-1~stretch",
- "NJS_VERSION=1.15.9.0.2.8-1~stretch"
- ],
- "Cmd": [
- "nginx",
- "-g",
- "daemon off;"
- ],
- "ArgsEscaped": true,
- "Image": "nginx",
- "Volumes": null,
- "WorkingDir": "",
- "Entrypoint": null,
- "OnBuild": null,
- "Labels": {
- "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
- },
- "StopSignal": "SIGTERM"
- },
- "NetworkSettings": {
- "Bridge": "",
- "SandboxID": "c107fe699256ce2babfe253697e8920386d06d86dae4d91be13c0b6cca00aa08",
- "HairpinMode": false,
- "LinkLocalIPv6Address": "",
- "LinkLocalIPv6PrefixLen": ,
- "Ports": {
- "80/tcp": [
- {
- "HostIp": "0.0.0.0",
- "HostPort": ""
- }
- ]
- },
- "SandboxKey": "/var/run/docker/netns/c107fe699256",
- "SecondaryIPAddresses": null,
- "SecondaryIPv6Addresses": null,
- "EndpointID": "88fa96a128cc924a9117cae0f720609ed70cad716892da3baf598e7f58a03ecc",
- "Gateway": "172.17.0.1",
- "GlobalIPv6Address": "",
- "GlobalIPv6PrefixLen": ,
- "IPAddress": "172.17.0.2",
- "IPPrefixLen": ,
- "IPv6Gateway": "",
- "MacAddress": "02:42:ac:11:00:02",
- "Networks": {
- "bridge": {
- "IPAMConfig": null,
- "Links": null,
- "Aliases": null,
- "NetworkID": "43fd51e168684e9ecd3684cf50beff2305983c747083d35e2b8a04d3470d775b",
- "EndpointID": "88fa96a128cc924a9117cae0f720609ed70cad716892da3baf598e7f58a03ecc",
- "Gateway": "172.17.0.1",
- "IPAddress": "172.17.0.2",
- "IPPrefixLen": ,
- "IPv6Gateway": "",
- "GlobalIPv6Address": "",
- "GlobalIPv6PrefixLen": ,
- "MacAddress": "02:42:ac:11:00:02",
- "DriverOpts": null
- }
- }
- }
- }
- ]
7、停止Nginx应用
- [root@localhost ~]# docker ps
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- ad7cc45c81ff nginx "nginx -g 'daemon of…" seconds ago Up seconds 0.0.0.0:->/tcp myNginx
- [root@localhost ~]# docker stop ad7cc45c81ff
- ad7cc45c81ff
8、查看Nginx进程,访问80端口
- [root@localhost ~]# ps -ef|grep nginx
- root : pts/ :: grep --color=auto nginx
- [root@localhost ~]# curl http://localhost:80/
- curl: () Failed connect to localhost:; Connection refused
9、删除Nginx应用Container(一般需要先停止后才能删除,强制删除使用 docker rm -f xxx)
- [root@localhost ~]# docker stop ad7cc45c81ff
- ad7cc45c81ff
- [root@localhost ~]# docker rm ad7cc45c81ff
- ad7cc45c81ff
10、Docker的Nginx应用映射到主机8899端口
- [root@localhost ~]# curl http://localhost:8899/
- curl: () Failed connect to localhost:; Connection refused
- [root@localhost ~]# docker run -p : --name myNginx -d nginx
- 598c5f3d52e0511480eebb031c2cdee05b155054edd014ca22ca1bef49d62867
- [root@localhost ~]# curl http://localhost:8899/
- <!DOCTYPE html>
- <html>
- <head>
- <title>Welcome to nginx!</title>
- <style>
- body {
- width: 35em;
- margin: 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>
Docker部署Nginx应用(2)的更多相关文章
- Docker部署Nginx并修改配置文件
Docker部署Nginx并修改配置文件 一.拉取nginx镜像 docker pull nginx 二.在宿主机中创建挂载目录 mkdir -p /data/nginx/{conf,conf.d,h ...
- docker(部署常见应用):docker部署nginx
上回说到centos安装docker. 这次用实战,docker部署运行常见的应用. docker常用命令 参看:docker命令大全.这里不做赘述. docker部署nginx 1.docker h ...
- 使用docker部署nginx+tomcat架构(3):使用docker-compose简化部署操作
经历了之前的两篇,我们已经大体上了解了docker部署容器的过程. 使用docker部署nginx+tomcat架构 使用docker部署nginx+tomcat架构():访问mysql数据库 不过, ...
- 使用docker部署nginx+tomcat架构(2):访问mysql数据库
上一篇完成了通过docker部署nginx+tomcat的基础软件架构,但是距离一个真正可用的软件架构还差得很远.其中最重要的一点是缺少数据库这个角色的存在,那么本篇就来完善这一点. 废话少说,直接进 ...
- 【原创】大数据基础之Mesos+Marathon+Docker部署nginx
一 安装 安装docker:https://www.cnblogs.com/barneywill/p/10343091.html安装mesos:https://www.cnblogs.com/barn ...
- docker 部署nginx 使用keepalived 部署高可用
一.体系架构 在Keepalived + Nginx高可用负载均衡架构中,keepalived负责实现High-availability (HA) 功能控制前端机VIP(虚拟网络地址),当有设备发生故 ...
- docker 部署 nginx+php+mysql
系统:centos7 使用root账户 开放80端口 firewall-cmd --zone=public --add-port=80/tcp --permanent 安装docker yum ins ...
- 【转载】Docker部署nginx并修改配置文件
docker 部署个nginx docker run \ --name nginx-health-web-pc \ -d -p 6800:80 \ -v /usr/docker/nginx/html: ...
- 使用docker部署nginx+tomcat架构
架构说明: 使用nginx+tomcat实现动态/静态(资源请求)分离和负载均衡. 参考文档: https://www.runoob.com/docker/docker-tutorial.html 配 ...
随机推荐
- MySQL 存储过程 -流程控制的使用
#五.流程控制的使用 #1.IF 使用 create PROCEDURE iftest1() BEGIN DECLARE a int DEFAULT 10; -- IF (a>1 &&a ...
- [GO]定时器的停止和重置
package main import ( "time" "fmt" ) func main() { timer := time.NewTimer( * tim ...
- libxml2
http://www.xmlsoft.org/downloads.html 建议直接用openscenegraph下载的3rdparty:http://www.openscenegraph.org ...
- 手动安装Chrome截屏控件扩展-Xproer.ScreenCapture(ScreenCapture.crx)
1.打开扩展面板,在地址栏中输入 chrome://extensions 或通过"扩展程序"菜单打开 2.将ScreenCapture.crx拖拽到此面板中 3.选择添 ...
- form action 相对路径出问题
http://www.w3chtml.com/html5/tag/base.html <base> 标签为页面上的所有链接规定默认地址或默认目标. 通常情况下,浏览器会从当前文档的 URL ...
- Tango Java API常数
Tango Java API Constants常数 Constant Field Values常数字段值 Contents com.google.* com.google.* com.google. ...
- FileInputStream和FileOutStream的使用——文件字节输入/输出流
最近又退回到java EE的学习,这篇博客就来讲解一下字节流中最重要的两个类FileInputStream和FileOutputStream的用法: FileInputStream:全称是文件字节输入 ...
- DLL的概念、dll导出类(转贴)
1. DLL的概念DLL(Dynamic Linkable Library),动态链接库,可以向程序提供一些函数.变量或类.这些可以直接拿来使用.静态链接库与动态链接库的区别:(1)静态链接库与动态链 ...
- 谷歌三大核心技术(一)Google File System中文版
http://www.open-open.com/lib/view/open1328763454608.html
- map的回调函数
问题:--js (['1','2','3']).map(parseInt) 第一眼看到这个题目的时候,脑海跳出的答案是 [1, 2, 3],但是真正的答案是[1, NaN, NaN]. 首先让我们 ...