其他
小网站的容器化(下):网站容器化的各种姿势,先跟着撸一波代码再说!
作者 | 王洪鹏
责编 | Carol
出品 | CSDN云计算(ID:CSDNcloud)
封图| CSDN下载于视觉中国
Trying to pull repository hub.c.163.com/public/tomcat ...
7.0.28: Pulling from hub.c.163.com/public/tomcat
f46924f139ed: Already exists
a3ed95caeb02: Pull complete
4849cac99801: Already exists
5e90c4274a33: Pull complete
e8f49ae1f54f: Pull complete
cfd12ae39390: Pull complete
1065252df5d5: Pull complete
0fe337adb9c6: Pull complete
9e5f36235195: Pull complete
7edf271c9251: Pull complete
c255b3c6176a: Pull complete
d1aa8ac63c58: Pull complete
f9ab623b3035: Pull complete
f7da31d1f835: Pull complete
48e150291322: Pull complete
069d27b85888: Pull complete
1835e80c6480: Pull complete
Digest: sha256:dd6c708e981e61f6aae56dac2ef91a78b28e0589743b44b7f174a57b1f097154
Status: Downloaded newer image for hub.c.163.com/public/tomcat:7.0.28
c64f076c3fda8d3183e570ad2af7253340de4fb48d098b6608f89fbf7715af0c
[root@localhost ~]# docker run --name tomcat -d -p 8080:8080 hub.c.163.com/public/tomcat:7.0.28
9a1e7c9909b8ce0299feecb5d424e16f8769476ef31d237ada8b8827c2106265
[root@localhost ~]# hostname -I
192.168.19.128 192.168.122.1 172.17.0.1
tcp6 0 0 :::8080 :::* LISTEN 48830/docker-proxy
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
etodule_hotfixes=true
Loaded plugins: fastestmirror, langpacks
Cleaning repos: Ceph Ceph-noarch ceph-source epel kubernetes nginx-stable
Cleaning up everything
Cleaning up list of fastest mirrors
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2020-03-19 03:46:00 PDT; 6s ago
Docs: http://nginx.org/en/docs/
Process: 27957 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 27958 (nginx)
Memory: 2.9M
CGroup: /system.slice/nginx.service
├─27958 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─27959 nginx: worker process
Mar 19 03:46:00 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
Mar 19 03:46:00 localhost.localdomain systemd[1]: PID file /var/run/nginx.pid not readable (yet?) after start.
Mar 19 03:46:00 localhost.localdomain systemd[1]: Started nginx - high performance web server.
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@localhost conf.d]# ls
default.conf
[root@localhost conf.d]# vim vhost.conf
{
listen 80;
server_name test.tomcat.com;
location / {
proxy_pass http://127.0.0.1:8080;
}
}
[root@localhost conf.d]# systemctl status nginx
##### self test
http.createServer(function (request, response) {
// 发送 HTTP 头部
// HTTP 状态值: 200 : OK
// 内容类型: text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});
// 发送响应数据 "Hello World"
response.end('Hello World\n');
}).listen(8888);
// 终端打印如下信息
console.log('Server running at http://127.0.0.1:8888/');
[1] 128553
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
tcp6 0 0 :::8888 :::* LISTEN 128553/node
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2020-03-29 21:50:24 PDT; 6h ago
Docs: http://nginx.org/en/docs/
Process: 10503 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 128736 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 128737 (nginx)
CGroup: /system.slice/nginx.service
├─128737 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─128738 nginx: worker process
Mar 29 21:50:23 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
Mar 29 21:50:24 localhost.localdomain systemd[1]: Started nginx - high performance web server.
4.5.2: Pulling from hub.c.163.com/public/wordpress
f46924f139ed: Already exists
a3ed95caeb02: Pull complete
4849cac99801: Already exists
682d1e7cffd4: Pull complete
162c309da2f9: Pull complete
2161e9680cdd: Pull complete
43391942ffef: Pull complete
d77d4c0e8fd0: Pull complete
6a6f091f97d8: Pull complete
53fa8ad0f2eb: Pull complete
28ee09fdd4e4: Pull complete
df176ee322b5: Pull complete
44104685ee03: Pull complete
1822edc7ae75: Pull complete
ecfd62e25a20: Pull complete
f3c6ecfde54e: Pull complete
81113ad0b0e3: Pull complete
bb5c02f581db: Pull complete
1a10055e720e: Pull complete
Digest: sha256:894e1cd6b398ea895f94d803e6de71c12c9b68fa3663e10c96ed4bc22adcb54a
Status: Downloaded newer image for hub.c.163.com/public/wordpress:4.5.2
ae09f3291607130bd78186caadb02d0ba8af5d684b82165ab19cd89c1a145833
tcp6 0 0 :::8082 :::* LISTEN 4259/docker-proxy
root@ae09f3291607:/var/www# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 4192 576 ? Ss 04:36 0:00 /bin/sh -c /etc/init.d/mysql start && /tmp/entrypoint-wd.sh apache2 && /usr/sbin/sshd -D || /usr/sbin/sshd -D
root 34 0.0 0.0 4192 708 ? S 04:36 0:00 /bin/sh /usr/bin/mysqld_safe
mysql 363 0.1 6.4 371504 64136 ? Sl 04:36 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --pid-file=/var/run/mysqld/mysqld.pid
root 364 0.0 0.0 4100 632 ? S 04:36 0:00 logger -t mysqld -p daemon.error
root 617 0.0 0.9 158924 9588 ? Ss 04:37 0:00 /usr/sbin/apache2 -k start
root 619 0.0 0.3 49952 3028 ? S 04:37 0:00 /usr/sbin/sshd -D
www-data 621 0.0 0.6 158956 6008 ? S 04:37 0:00 /usr/sbin/apache2 -k start
www-data 622 0.0 0.6 158956 6008 ? S 04:37 0:00 /usr/sbin/apache2 -k start
www-data 623 0.0 0.6 158956 6008 ? S 04:37 0:00 /usr/sbin/apache2 -k start
www-data 624 0.0 0.6 158956 6008 ? S 04:37 0:00 /usr/sbin/apache2 -k start
www-data 625 0.0 0.6 158956 6008 ? S 04:37 0:00 /usr/sbin/apache2 -k start
root 626 2.3 0.1 17836 1840 ? Ss 04:41 0:00 bash
root 631 0.0 0.1 15320 1136 ? R+ 04:41 0:00 ps aux
[root@localhost ~]# ls /data/mysql
debian-5.5.flag ibdata1 ib_logfile0 ib_logfile1 mysql mysql_upgrade_info performance_schema wordpress
Wordpress
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@localhost ~]#
{
listen 80;
server_name test.tomcat.com;
location / {
proxy_pass http://127.0.0.1:8080;
}
}
server
{
listen 80;
server_name test.node.com;
location / {
proxy_pass http://127.0.0.1:8888;
}
}
server
{
listen 80;
server_name test.wordpress.com;
location / {
proxy_pass http://127.0.0.1:8082;
}
}
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2020-04-02 04:37:09 PDT; 6s ago
Docs: http://nginx.org/en/docs/
Process: 47753 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 47774 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 47775 (nginx)
CGroup: /system.slice/nginx.service
├─47775 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─47776 nginx: worker process
Apr 02 04:37:09 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
Apr 02 04:37:09 localhost.localdomain systemd[1]: Started nginx - high performance web server.
你知道吗?其实 Oracle 直方图自动统计算法存在这些缺陷!(附验证步骤) 你公司的虚拟机还闲着?基于 Jenkins 和 Kubernetes 的持续集成测试实践了解一下! 一站式杀手级 AI 开发平台来袭!告别切换零散建模工具 那些神一样的程序员 比特币当赎金,WannaRen 勒索病毒二度来袭! 通过 Python 代码实现时间序列数据的统计学预测模型
真香,朕在看了!