vi /sh/scp-docker.sh
#### 同步远程的docker镜像自动装载
C#代码
- cd /data/backup &&
- scp root@172.16.207.22:/data/backup/* ./ &&
- docker stop nginx-nodejs-redis:v2b &&
- docker rm nginx-nodejs-redis:v2b &&
- docker stop jenkins-rsync:v2b &&
- docker rm jenkins-rsync:v2b &&
- docker rmi nginx-nodejs-redis:v2b &&
- docker rmi jenkins-rsync:v2b &&
- docker image load -i jenkins-rsync-v2b.tgz &&
- docker image load -i nginx-nodejs-redis-v2b.tgz &&
- rm -rf /data/apps &&
- mkdir -p /data/apps/nginx/htdocs &&
- mkdir -p /data/apps/redis/htdocs &&
- mkdir -p /data/apps/rsync/www &&
- mkdir -p /data/apps/nodejs/htdocs/nest/KTM/dist &&
- mkdir -p /data/apps/nodejs/htdocs/nest/KTM/public &&
- mkdir -p /data/apps/nodejs/htdocs/nest/do_nest/public/www &&
- mkdir -p /data/apps/nodejs/htdocs/nest/other &&
- docker run \
- -u root \
- -p 80:80 \
- -p 8080:80 \
- -p 3000:3000 \
- -p 6379:6379 \
- -v /data/apps/nginx/htdocs:/data/nginx/htdocs \
- -v /data/apps/redis/htdocs:/data/redis/htdocs \
- -v /data/apps/rsync:/data/rsync \
- -v /data/apps/nodejs/htdocs/nest/KTM/dist:/data/nodejs/htdocs/nest/KTM/dist \
- -v /data/apps/nodejs/htdocs/nest/KTM/public:/data/nodejs/htdocs/nest/KTM/public \
- -v /data/apps/nodejs/htdocs/nest/do_nest/public/www:/data/nodejs/htdocs/nest/do_nest/public/www \
- -v /data/apps/nodejs/htdocs/nest/other:/data/nodejs/htdocs/nest/other \
- --privileged=true \
- --name=nginx-nodejs-redis-v2b \
- -d --restart=always nginx-nodejs-redis:v2b &&
- docker run -p 4440:8080 -p 5000:5000 -p 8730:873 \
- -u root \
- --name=jenkins-rsync-v2b \
- --privileged=true \
- -v /etc/localtime:/etc/localtime \
- -v /data/apps/jenkins_home:/data/jenkins \
- -v /data/apps/rsync/www:/data/rsync/www \
- -d --restart=always jenkins-rsync:v2b
### 重启定时器服务
chmod 755 /sh/scp-docker.sh
systemctl restart crond
### 编辑和查看定时器配置
crontab -e
crontab -l
### 每天的2:10重启smb
10 2 * * * /sh/scp-docker.sh