jenkins
CI/CD
docker build
docker run
执行脚本,打包项目镜像
启动容器并挂载数据卷
mkdir -p /dockerapp/nginx/www /dockerapp/ngxin/conf /dockerapp/nginx/logs
docker run -it -p 8081:80 --name dockerapp01 -v /dockerapp/nginx/conf:/etc/nginx 4f361dbcbce5 /bin/bash
无法访问
curl localhost:8081
curl: (56) Recv failure: Connection reset by peer
防火墙状态正常
systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since Tue 2021-01-05 17:48:36 CST; 8 months 28 days ago
Docs: man:firewalld(1)
Main PID: 1834 (firewalld)
Tasks: 2
Memory: 4.9M
CGroup: /system.slice/firewalld.service
└─1834 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
Oct 01 20:45:40 iZm5e23n3ueobwkjtfartxZ firewalld[1834]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It... it now.
Oct 01 20:45:41 iZm5e23n3ueobwkjtfartxZ firewalld[1834]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i docker0 -o docker0 -j DROP' fa...chain?).
Oct 01 20:45:41 iZm5e23n3ueobwkjtfartxZ firewalld[1834]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i docker0 -o docker0 -j DROP' fa...chain?).
Oct 02 19:06:58 iZm5e23n3ueobwkjtfartxZ firewalld[1834]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It... it now.
Oct 02 19:06:59 iZm5e23n3ueobwkjtfartxZ firewalld[1834]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i docker0 -o docker0 -j DROP' fa...chain?).
Oct 02 19:06:59 iZm5e23n3ueobwkjtfartxZ firewalld[1834]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i docker0 -o docker0 -j DROP' fa...chain?).
Oct 03 20:30:03 iZm5e23n3ueobwkjtfartxZ firewalld[1834]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i br-799426d70aa2 -o br-799426d7...chain?).
Oct 04 10:02:19 iZm5e23n3ueobwkjtfartxZ firewalld[1834]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i br-9fb064c034b1 -o br-9fb064c0...chain?).
Oct 04 10:18:09 iZm5e23n3ueobwkjtfartxZ firewalld[1834]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i br-0096a971fd2c -o br-0096a971...chain?).
Oct 04 11:04:50 iZm5e23n3ueobwkjtfartxZ firewalld[1834]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i br-0350d84612be -o br-0350d846...chain?).
Hint: Some lines were ellipsized, use -l to show in full.
[root@--- financial-innovation-h5]#
- 在nginx镜像基础之上把自己的前端项目打包成镜像
- 运行镜像,启动容器
- 浏览器访问
FROM nginx:1.17.3
ADD h5.tar.gz /usr/share/nginx/html
步骤上没有任何问题,没有参考任何文档,实测发现容器启动了,但是容器里面的nginx服务并没有启动,导致内网和浏览器访问不同,
解决:
进入容器,启动服务
cd /etc/init.d
.nginx start
浏览器即可访问
启动容器跟启动容器内的服务是两码事
守护态运行
docker run -d ubuntu:18.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
问题扩展 怎么接上Jenkins,完成CI/CD