Docker- 常用部署目录及脚本
1. 目录结构如下
PS H:\Docker集群部署脚本目录结构及脚本> dir
目录: H:\Docker集群部署脚本目录结构及脚本
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2019/12/14 23:14 code
-a---- 2019/12/14 23:12 609 build.sh
-a---- 2019/8/13 18:58 449 docker-compose.yml
-a---- 2019/8/13 18:56 2065 Dockerfile
-a---- 2019/12/14 23:22 515 README.md
2. 构建镜像脚本及推送仓库
#!/bin/bash
# program: build docker image
# author:python
# date:2019-08-13
# docker image name 【后期构建其他的项目时需要修改下面的镜像名称】
IMAGE_NAME="rc_check_service:`date +%Y%m%d`"
#
# docker Dockerfile path 【dockerfile文件的路径】
DOCKER_PATH="."
#
# docker hup 【上传到本地仓库以备利用???】
DOCKER_HUP="localhost:5000/"
#
# docker build
docker build --build-arg DB_PUBKEY=$DB_PUBKEY -t $IMAGE_NAME $DOCKER_PATH
# docker tag
docker tag $IMAGE_NAME $DOCKER_HUP$IMAGE_NAME
#docker push
docker push $DOCKER_HUP$IMAGE_NAME
3. docker-compose.yml 文件简介
version: '3'
services:
rc_check_service:
image: rc_check_service:20190813
restart: always
ports:
# - "9600:19001"
- "8600:8600"
networks:
- service-net
container_name: rc_check_service
volumes:
- /app/logs/rc-sunxiuwen/check_service:/app/logs
- /app/logs/rc-sunxiuwen/check_service:/app/python_apps_logs
environment:
- LOG_PREFIX=/opt/logs
networks:
service-net:
人生苦短,我用python!