释放双眼,带上耳机,听听看~!
默认情况下,docker compose运行harbor的时候,harbor服务在机器重启后无法自动拉起,接下里我们通过启动命令脚本,每次开机自动拉起harbor
root@harbor:~/harbor# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d32813f00977 goharbor/harbor-log:v2.13.2 "/bin/sh -c /usr/loc…" 4 days ago Up 3 hours (healthy) 127.0.0.1:1514->10514/tcp harbor-log
root@harbor:~/harbor#
root@harbor:~/harbor# docker ps --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
105f40ff57e1 goharbor/nginx-photon:v2.13.2 "nginx -g 'daemon of…" 4 days ago Exited (128) 3 hours ago nginx
5531bf290eba goharbor/harbor-jobservice:v2.13.2 "/harbor/entrypoint.…" 4 days ago Exited (128) 3 hours ago harbor-jobservice
0993f05fda30 goharbor/harbor-core:v2.13.2 "/harbor/entrypoint.…" 4 days ago Exited (128) 3 hours ago harbor-core
d383607b0666 goharbor/harbor-registryctl:v2.13.2 "/home/harbor/start.…" 4 days ago Exited (128) 3 hours ago registryctl
5531198e2b0a goharbor/registry-photon:v2.13.2 "/home/harbor/entryp…" 4 days ago Exited (128) 3 hours ago registry
55645b0d3c38 goharbor/harbor-portal:v2.13.2 "nginx -g 'daemon of…" 4 days ago Exited (128) 3 hours ago harbor-portal
2e7782ce11ff goharbor/redis-photon:v2.13.2 "redis-server /etc/r…" 4 days ago Exited (128) 3 hours ago redis
9127b002b43e goharbor/harbor-db:v2.13.2 "/docker-entrypoint.…" 4 days ago Exited (128) 3 hours ago harbor-db
d32813f00977 goharbor/harbor-log:v2.13.2 "/bin/sh -c /usr/loc…" 4 days ago Up 3 hours (healthy) 127.0.0.1:1514->10514/tcp harbor-log
解决方法
cat >> /etc/profile.d/docker.sh <<EOF
docker compose -f /root/harbor/docker-compose.yml down &> /dev/null
docker compose -f /root/harbor/docker-compose.yml up -d &> /dev/null
EOF
#/root/harbor为服务目录,自行替换
chmod +x /etc/profile.d/docker.sh
手动执行测试
root@harbor:~# sh /etc/profile.d/docker.sh
[+] Running 10/10
✔ Network harbor_harbor Created 0.1s
✔ Container harbor-log Started 0.9s
✔ Container harbor-portal Started 1.1s
✔ Container registryctl Started 1.1s
✔ Container registry Started 1.0s
✔ Container redis Started 1.2s
✔ Container harbor-db Started 1.1s
✔ Container harbor-core Started 1.3s
✔ Container harbor-jobservice Started 1.7s
✔ Container nginx Started 1.6s
root@harbor:~#
root@harbor:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b95315cc013c goharbor/nginx-photon:v2.13.2 "nginx -g 'daemon of…" 11 seconds ago Up 10 seconds (health: starting) 0.0.0.0:80->8080/tcp, [::]:80->8080/tcp, 0.0.0.0:443->8443/tcp, [::]:443->8443/tcp nginx
9d2e997ee2be goharbor/harbor-jobservice:v2.13.2 "/harbor/entrypoint.…" 11 seconds ago Up 5 seconds (health: starting) harbor-jobservice
f18c9381f42e goharbor/harbor-core:v2.13.2 "/harbor/entrypoint.…" 11 seconds ago Up 10 seconds (health: starting) harbor-core
33906c458fcd goharbor/redis-photon:v2.13.2 "redis-server /etc/r…" 11 seconds ago Up 10 seconds (health: starting) redis
55acee039d8e goharbor/harbor-registryctl:v2.13.2 "/home/harbor/start.…" 11 seconds ago Up 10 seconds (health: starting) registryctl
81b6acf55ebf goharbor/harbor-db:v2.13.2 "/docker-entrypoint.…" 11 seconds ago Up 10 seconds (health: starting) harbor-db
ab8832e06597 goharbor/registry-photon:v2.13.2 "/home/harbor/entryp…" 11 seconds ago Up 10 seconds (health: starting) registry
3a2580a1131d goharbor/harbor-portal:v2.13.2 "nginx -g 'daemon of…" 11 seconds ago Up 10 seconds (health: starting) harbor-portal
2911d5035366 goharbor/harbor-log:v2.13.2 "/bin/sh -c /usr/loc…" 11 seconds ago Up 11 seconds (health: starting) 127.0.0.1:1514->10514/tcp harbor-log
root@harbor:~#
重启节点验证
root@harbor:~# reboot
效果如下


