├── .github
└── stale.yml
├── .gitignore
├── .readthedocs.yaml
├── LICENSE
├── README.md
├── dockerfiles
├── alpine
│ └── Dockerfile
├── baota
│ ├── README.md
│ └── deploy.sh
├── cplusplus_hello-world
│ ├── CMakeLists.txt
│ ├── Dockerfile
│ ├── Dockerfile.build
│ ├── build.sh
│ ├── main.cpp
│ ├── test.cpp
│ └── test.h
├── cplusplus_hello-world_multi-stage
│ ├── CMakeLists.txt
│ ├── Dockerfile
│ ├── build.sh
│ ├── main.cpp
│ ├── test.cpp
│ └── test.h
├── gosu
│ ├── Dockerfile
│ ├── build.sh
│ ├── docker-entrypoint.sh
│ └── run.sh
├── hello-world
│ ├── Dockerfile
│ └── app.sh
├── ubuntu18.04_ssh
│ └── Dockerfile
└── ubuntu18.04_zh_CN
│ ├── Dockerfile
│ └── sources.list
├── docs
├── ci
│ └── jenkins.md
├── compose
│ ├── compose安装.md
│ ├── docker-compose-docker-run.md
│ ├── imgs
│ │ └── compose-docker.png
│ ├── 文件格式-service设置.md
│ ├── 文件格式-存储设置.md
│ ├── 文件格式概述.md
│ ├── 版本依赖.md
│ └── 译-docker-compose概述.md
├── docker
│ ├── advanced
│ │ ├── aliyun-镜像加速.md
│ │ ├── alpine-源配置.md
│ │ ├── docker-DNS设置.md
│ │ ├── docker-ssh-远程登录.md
│ │ ├── dockerignore.md
│ │ ├── hello-world.md
│ │ ├── imgs
│ │ │ ├── diff_dev_prod.png
│ │ │ ├── docker-nvidia.png
│ │ │ ├── go-format.png
│ │ │ └── match_rule.png
│ │ ├── ubuntu-18_04-中文环境配置.md
│ │ ├── ubuntu-nvidia-docker安装.md
│ │ ├── 在容器内部使用docker.md
│ │ └── 译-Docker开发最佳实践.md
│ ├── basic
│ │ ├── docker-hub使用.md
│ │ ├── docker安装.md
│ │ ├── docker定位.md
│ │ ├── imgs
│ │ │ ├── Container@2x.png
│ │ │ ├── VM@2x.png
│ │ │ ├── architecture.svg
│ │ │ ├── commit-options.png
│ │ │ ├── engine-components-flow.png
│ │ │ └── laurel-docker-containers.png
│ │ ├── 保存容器为镜像.md
│ │ ├── 可选设置.md
│ │ ├── 守护进程管理.md
│ │ ├── 搜索镜像.md
│ │ ├── 译-docker概述.md
│ │ ├── 镜像和容器.md
│ │ └── 镜像迁移.md
│ ├── dockerfile
│ │ ├── ADD和COPY.md
│ │ ├── ARG.md
│ │ ├── CMD.md
│ │ ├── ENTRYPOINT.md
│ │ ├── ENV.md
│ │ ├── EXPOSE.md
│ │ ├── FROM.md
│ │ ├── LABEL.md
│ │ ├── RUN.md
│ │ ├── SHELL.md
│ │ ├── WORKDIR.md
│ │ ├── [译]Dockerfile编写最佳实践.md
│ │ ├── dockerfile编写.md
│ │ ├── imgs
│ │ │ └── cmd-entrypoint.png
│ │ └── 多阶段构建.md
│ ├── gui
│ │ ├── deepwine.md
│ │ ├── index.md
│ │ ├── wps.md
│ │ └── 最佳实践.md
│ ├── index.md
│ ├── storage
│ │ ├── bind-propagation设置.md
│ │ ├── gosu-绑定挂载最佳实践.md
│ │ ├── imgs
│ │ │ ├── propagation-options.png
│ │ │ ├── types-of-mounts-bind.png
│ │ │ ├── types-of-mounts-volume.png
│ │ │ ├── types-of-mounts.png
│ │ │ └── volumes-shared-storage.svg
│ │ ├── 使用卷管理数据.md
│ │ ├── 创建和管理卷.md
│ │ ├── 挂载标识符解析.md
│ │ ├── 绑定挂载.md
│ │ └── 译-在Docker中管理数据.md
│ └── troubleshooting.md
├── flask
│ └── 文件服务器.md
├── index.md
├── network
│ ├── advanced
│ │ ├── docker-ubuntu-18_04-网络工具安装.md
│ │ ├── namesilo-dnspod-域名申请和解析.md
│ │ ├── nc-远程端口查询.md
│ │ ├── netplan.md
│ │ ├── netstat-端口查询.md
│ │ ├── nslookup-域名解析.md
│ │ ├── ubuntu-18_04-wifi信息查询.md
│ │ ├── ubuntu-18_04-公共DNS设置.md
│ │ └── 阿里云-域名解析-URL转发.md
│ ├── basic
│ │ ├── DNS解析过程.md
│ │ ├── URL构成.md
│ │ ├── imgs
│ │ │ ├── OSI.PNG
│ │ │ ├── URI_syntax_diagram.svg.png
│ │ │ ├── device-structure.PNG
│ │ │ ├── ip-address.PNG
│ │ │ ├── network-scope.PNG
│ │ │ ├── osi-tcp-ip.PNG
│ │ │ └── tcp-ip.PNG
│ │ ├── ip地址.md
│ │ ├── 局域网-广域网-互联网-私有专用网.md
│ │ ├── 私有地址.md
│ │ ├── 网络体系结构.md
│ │ └── 路由器-交换机-集线器-中继器.md
│ └── index.md
├── nginx
│ ├── advanced
│ │ ├── docker-nginx.md
│ │ ├── imgs
│ │ │ ├── aliyun-ca.png
│ │ │ ├── hello-nginx.png
│ │ │ ├── nginx-jenkins.png
│ │ │ ├── purchased-ca.png
│ │ │ ├── reverse_proxy.png
│ │ │ └── welcome-nginx.png
│ │ ├── 反向代理.md
│ │ ├── 多域名配置同一端口.md
│ │ ├── 文件共享服务.md
│ │ ├── 腾讯云-配置https.md
│ │ ├── 译-nginx-reverse-proxy.md
│ │ └── 阿里云-配置https.md
│ └── base
│ │ ├── imgs
│ │ ├── first-index.png
│ │ └── welcome_nginx.png
│ │ ├── 中文乱码.md
│ │ ├── 安装.md
│ │ ├── 托管网站.md
│ │ ├── 测试.md
│ │ └── 配置.md
├── penetration
│ ├── imgs
│ │ ├── oray-login.png
│ │ ├── port-setting.png
│ │ ├── router-visual-setting.png
│ │ └── switch-account.png
│ ├── index.md
│ ├── n2n
│ │ ├── imgs
│ │ │ ├── n2n_com.png
│ │ │ ├── n2n_nat.png
│ │ │ └── n2n_network.png
│ │ ├── n2n原理.md
│ │ └── n2n实现.md
│ ├── ngrok
│ │ ├── imgs
│ │ │ ├── ngrok-connect.png
│ │ │ ├── ngrok.png
│ │ │ ├── ngrok_online.png
│ │ │ ├── ngrok_online2.png
│ │ │ └── tunnels_online.png
│ │ ├── index.md
│ │ ├── ngrok-docker.md
│ │ ├── ngrok实现.md
│ │ ├── tcp-http-连接配置.md
│ │ └── ubuntu-service.md
│ ├── 花生壳.md
│ └── 路由器-虚拟服务器.md
├── requirements.txt
├── ssh
│ ├── advanced
│ │ ├── ssh-agent-代理设置.md
│ │ ├── ssh-禁用公钥检查.md
│ │ ├── 复制公钥到远程服务器.md
│ │ ├── 添加私钥缓存.md
│ │ └── 端口转发.md
│ ├── base
│ │ ├── http和ssh协议.md
│ │ ├── ssh-客户端配置文件.md
│ │ ├── ssh-常用工具.md
│ │ ├── ssh-生成密钥.md
│ │ └── ssh-远程连接.md
│ └── troubleshooting.md
└── tomcat
│ ├── imgs
│ └── tomcat-8080.png
│ ├── ubuntu-16_02-tomcat9安装.md
│ ├── 关于Tomcat.md
│ └── 非root用户运行.md
├── flaskapps
└── fileserver
│ ├── __init__.py
│ ├── app.py
│ └── uploads
│ └── lena.jpg
├── imgs
├── Deploy.png
└── Deploy.svg
├── mkdocs.yml
└── requirements.txt
/.github/stale.yml:
--------------------------------------------------------------------------------
1 | # Number of days of inactivity before an issue becomes stale
2 | daysUntilStale: 60
3 | # Number of days of inactivity before a stale issue is closed
4 | daysUntilClose: 7
5 | # Issues with these labels will never be considered stale
6 | exemptLabels:
7 | - pinned
8 | - security
9 | # Label to use when marking an issue as stale
10 | staleLabel: wontfix
11 | # Comment to post when marking an issue as stale. Set to `false` to disable
12 | markComment: >
13 | This issue has been automatically marked as stale because it has not had
14 | recent activity. It will be closed if no further activity occurs. Thank you
15 | for your contributions.
16 | # Comment to post when closing a stale issue. Set to `false` to disable
17 | closeComment: false
--------------------------------------------------------------------------------
/.readthedocs.yaml:
--------------------------------------------------------------------------------
1 | # .readthedocs.yaml
2 | # Read the Docs configuration file
3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4 |
5 | # Required
6 | version: 2
7 |
8 | mkdocs:
9 | configuration: mkdocs.yml
10 |
11 | # Optionally set the version of Python and requirements required to build your docs
12 | python:
13 | version: 3.8
14 | install:
15 | - requirements: docs/requirements.txt
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | 语言:
3 | 🇨🇳
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | «Deploy»记录了远程连接/内网穿透/Web服务器/持续集成/容器/编排工具/编译工具的部署和使用
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | ## 内容列表
23 |
24 | - [内容列表](#内容列表)
25 | - [主要维护人员](#主要维护人员)
26 | - [参与贡献方式](#参与贡献方式)
27 | - [许可证](#许可证)
28 |
29 | ## 主要维护人员
30 |
31 | * zhujian - *Initial work* - [zjykzj](https://github.com/zjykzj)
32 |
33 | ## 参与贡献方式
34 |
35 | 欢迎任何人的参与!打开[issue](https://github.com/ZJDoc/Deploy/issues)或提交合并请求。
36 |
37 | 注意:
38 |
39 | * `GIT`提交,请遵守[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0-beta.4/)规范
40 | * 语义版本化,请遵守[Semantic Versioning 2.0.0](https://semver.org)规范
41 | * `README`编写,请遵守[standard-readme](https://github.com/RichardLitt/standard-readme)规范
42 |
43 | ## 许可证
44 |
45 | [Apache License 2.0](LICENSE) © 2021 zjykzj
--------------------------------------------------------------------------------
/dockerfiles/alpine/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM alpine:latest
2 | LABEL maintainer "zhujian "
3 |
4 | RUN set -eux && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
--------------------------------------------------------------------------------
/dockerfiles/baota/README.md:
--------------------------------------------------------------------------------
1 |
2 | # 宝塔面板部署
3 |
4 | ## 安装
5 |
6 | ```
7 | bash deploy.sh
8 | ```
9 |
10 | ## 登录方式
11 |
12 | * 登陆地址 http://{{面板ip地址}}:8888
13 |
14 | * 初始账号 username
15 |
16 | * 初始密码 password
17 |
18 | ## 用户名/密码出错
19 |
20 | 参考[初始的用户名密码登陆错误 #66 ](https://github.com/pch18-docker/baota/issues/66)
21 |
22 | ```
23 | 同密码错误
24 | 解决方法:
25 | docker exec -it baota bash
26 | 进入宝塔的docker容器内部
27 | 输入bt选择5和6修改账号密码
28 | ctrl+d退出容器且保持容器运行
29 | ```
30 |
31 | ## 相关阅读
32 |
33 | * [宝塔面板一键docker部署](https://hub.docker.com/r/pch18/baota)
--------------------------------------------------------------------------------
/dockerfiles/baota/deploy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker run -tid --name baota --net=host --privileged=true --shm-size=1g --restart always -v ~/wwwroot:/www/wwwroot pch18/baota
4 |
--------------------------------------------------------------------------------
/dockerfiles/cplusplus_hello-world/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.1)
2 | project(multi)
3 |
4 | set(CMAKE_CXX_FLAGS "-static ${CMAKE_CXX_FLAGS}")
5 | set(CMAKE_CXX_STANDARD 11)
6 |
7 | add_executable(app main.cpp test.cpp test.h)
--------------------------------------------------------------------------------
/dockerfiles/cplusplus_hello-world/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM alpine:latest
2 | LABEL maintainer "zhujian "
3 |
4 | WORKDIR /root/
5 | COPY app .
6 | ENTRYPOINT ["./app"]
--------------------------------------------------------------------------------
/dockerfiles/cplusplus_hello-world/Dockerfile.build:
--------------------------------------------------------------------------------
1 | FROM ubuntu:18.04
2 | LABEL maintainer "zhujian "
3 |
4 | RUN set -eux && \
5 | apt-get update && apt-get install -f && apt-get install -y make cmake gcc g++
6 | COPY CMakeLists.txt main.cpp test.cpp test.h /app/
7 | WORKDIR /app
8 | RUN cmake . && make
--------------------------------------------------------------------------------
/dockerfiles/cplusplus_hello-world/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -eux
4 |
5 | echo Building zjykzj/hello:build
6 |
7 | docker build -t zjykzj/hello:build . -f Dockerfile.build
8 |
9 | docker container create --name extract zjykzj/hello:build
10 | docker container cp extract:/app/app ./app
11 | docker container rm -f extract
12 |
13 | echo Building zjykzj/hello:latest
14 |
15 | docker build --no-cache -t zjykzj/hello:latest .
16 | rm ./app
--------------------------------------------------------------------------------
/dockerfiles/cplusplus_hello-world/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "test.h"
3 |
4 | int main() {
5 | Test test;
6 | test.PrintHello();
7 |
8 | std::cout << "Hello, World!" << std::endl;
9 | return 0;
10 | }
--------------------------------------------------------------------------------
/dockerfiles/cplusplus_hello-world/test.cpp:
--------------------------------------------------------------------------------
1 | #include "test.h"
2 | #include
3 |
4 | void Test::PrintHello() {
5 | std::cout << "Hello World" << std::endl;
6 | }
--------------------------------------------------------------------------------
/dockerfiles/cplusplus_hello-world/test.h:
--------------------------------------------------------------------------------
1 | #ifndef MULTI_TEST_H
2 | #define MULTI_TEST_H
3 |
4 | class Test {
5 | public:
6 | void PrintHello();
7 | };
8 |
9 | #endif //MULTI_TEST_H
--------------------------------------------------------------------------------
/dockerfiles/cplusplus_hello-world_multi-stage/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.1)
2 | project(multi)
3 |
4 | set(CMAKE_CXX_FLAGS "-static ${CMAKE_CXX_FLAGS}")
5 | set(CMAKE_CXX_STANDARD 11)
6 |
7 | add_executable(app main.cpp test.cpp test.h)
--------------------------------------------------------------------------------
/dockerfiles/cplusplus_hello-world_multi-stage/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:18.04
2 | LABEL maintainer "zhujian "
3 |
4 | RUN set -eux && \
5 | apt-get update && apt-get install -f && apt-get install -y make cmake gcc g++
6 | COPY CMakeLists.txt main.cpp test.cpp test.h /app/
7 | WORKDIR /app
8 | RUN cmake . && make
9 |
10 | FROM alpine:latest
11 | LABEL maintainer "zhujian "
12 |
13 | WORKDIR /root/
14 | COPY --from=0 /app/app .
15 | ENTRYPOINT ["./app"]
--------------------------------------------------------------------------------
/dockerfiles/cplusplus_hello-world_multi-stage/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -eux
4 |
5 | docker build -t zjykzj/hello:latest .
--------------------------------------------------------------------------------
/dockerfiles/cplusplus_hello-world_multi-stage/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "test.h"
3 |
4 | int main() {
5 | Test test;
6 | test.PrintHello();
7 |
8 | std::cout << "Hello, World!" << std::endl;
9 | return 0;
10 | }
--------------------------------------------------------------------------------
/dockerfiles/cplusplus_hello-world_multi-stage/test.cpp:
--------------------------------------------------------------------------------
1 | #include "test.h"
2 | #include
3 |
4 | void Test::PrintHello() {
5 | std::cout << "Hello World" << std::endl;
6 | }
--------------------------------------------------------------------------------
/dockerfiles/cplusplus_hello-world_multi-stage/test.h:
--------------------------------------------------------------------------------
1 | #ifndef MULTI_TEST_H
2 | #define MULTI_TEST_H
3 |
4 | class Test {
5 | public:
6 | void PrintHello();
7 | };
8 |
9 | #endif //MULTI_TEST_H
--------------------------------------------------------------------------------
/dockerfiles/gosu/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM zjykzj/ubuntu:18.04
2 | LABEL maintainer "zhujian "
3 |
4 | WORKDIR /app
5 | RUN set -eux && \
6 | apt-get update && \
7 | apt-get install -y gosu && \
8 | rm -rf /var/lib/apt/lists/* && \
9 | # verify that the binary works
10 | gosu nobody true && \
11 | useradd -s /bin/bash -m user
12 |
13 | COPY docker-entrypoint.sh .
14 | RUN chmod a+x docker-entrypoint.sh
15 |
16 | ENTRYPOINT ["/app/docker-entrypoint.sh"]
--------------------------------------------------------------------------------
/dockerfiles/gosu/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -eux
4 |
5 | docker build -t gosu_test .
--------------------------------------------------------------------------------
/dockerfiles/gosu/docker-entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ "$(id -u)" -eq '0' ]
4 | then
5 | USER_ID=${LOCAL_USER_ID:-9001}
6 |
7 | usermod -u ${USER_ID} -g ${USER_ID} user > /dev/null 2>&1
8 | chown -R `id -u user`:`id -u user` /app > /dev/null 2>&1
9 |
10 | export HOME=/home/user
11 | exec gosu user "$0" "$@"
12 | fi
13 |
14 | exec "$@"
--------------------------------------------------------------------------------
/dockerfiles/gosu/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -eux
4 |
5 | docker run -it --rm -e LOCAL_USER_ID=`id -u ${USER}` -v ${HOME}/storage:/home/user/storage gosu_test bash
--------------------------------------------------------------------------------
/dockerfiles/hello-world/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:18.04
2 | LABEL maintainer "zhujian "
3 |
4 | COPY . /app
5 | CMD sh /app/app.sh
--------------------------------------------------------------------------------
/dockerfiles/hello-world/app.sh:
--------------------------------------------------------------------------------
1 | echo 'Hello World'
2 |
--------------------------------------------------------------------------------
/dockerfiles/ubuntu18.04_ssh/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM zjykzj/ubuntu:18.04
2 | LABEL maintainer "zhujian "
3 |
4 | RUN apt-get update && apt-get install -y openssh-server
5 | RUN mkdir /var/run/sshd
6 | RUN echo 'root:THEPASSWORDYOUCREATED' | chpasswd
7 | RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
8 |
9 | # SSH login fix. Otherwise user is kicked off after login
10 | RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
11 |
12 | EXPOSE 22
13 | CMD ["/usr/sbin/sshd", "-D"]
--------------------------------------------------------------------------------
/dockerfiles/ubuntu18.04_zh_CN/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:18.04
2 | LABEL maintainer "zhujian "
3 |
4 | COPY sources.list .
5 | ENV DEBIAN_FRONTEND=noninteractive
6 | RUN set -eux && \
7 | rm /etc/apt/sources.list && \
8 | mv sources.list /etc/apt/sources.list && \
9 | apt-get update && \
10 | apt-get install -y locales tzdata xfonts-wqy && \
11 | locale-gen zh_CN.UTF-8 && \
12 | update-locale LANG=zh_CN.UTF-8 LANGUAGE=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8 && \
13 | ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
14 | dpkg-reconfigure --frontend noninteractive tzdata && \
15 | find /var/lib/apt/lists -type f -delete && \
16 | find /var/cache -type f -delete
17 |
18 | ENV LANG=zh_CN.UTF-8 LANGUAGE=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8
--------------------------------------------------------------------------------
/dockerfiles/ubuntu18.04_zh_CN/sources.list:
--------------------------------------------------------------------------------
1 | deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
2 |
3 | deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
4 |
5 | deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
6 |
7 | deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
8 |
9 | deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
10 |
11 | deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
12 |
13 | deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
14 |
15 | deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
16 |
17 | deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
18 |
19 | deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
--------------------------------------------------------------------------------
/docs/ci/jenkins.md:
--------------------------------------------------------------------------------
1 |
2 | # Jenkins
3 |
4 | ## 教程
5 |
6 | * [Jenkins安装](https://blog.zhujian.life/posts/5d15ec84.html)
7 | * [Jenkins 更换镜像源](https://blog.zhujian.life/posts/9ff7f63d.html)
8 | * [[Jenkins]手动下载插件](https://blog.zhujian.life/posts/373e88b0.html)
9 | * [[Jenkins]freestyle工程](https://blog.zhujian.life/posts/fddee3e1.html)
10 | * [[Jenkins][Freestyle]环境变量设置](https://blog.zhujian.life/posts/f2f14bee.html)
11 | * [[Jenkins][GitLab][Hexo]新建Freestyle工程实现CI功能](https://blog.zhujian.life/posts/446d640.html)
12 | * [[Jenkins][GitLab][Hexo]新建Pipeline工程实现CI功能](https://blog.zhujian.life/posts/f80ec296.html)
13 | * [[Jenkins]手动设置私钥](https://blog.zhujian.life/posts/c343c930.html)
14 | * [[Jenkins]Pipeline工程配置NodeJS环境](https://blog.zhujian.life/posts/d521b4ea.html)
15 | * [[Jenkins]语法查询](https://blog.zhujian.life/posts/bf0708ea.html)
16 | * Proxy
17 | * [[Jenkins]Tomcat托管](https://blog.zhujian.life/posts/bc77c204.html)
18 | * [[Jenkins][Nginx]反向代理](https://blog.zhujian.life/posts/7c823af7.html)
19 | * WebHook
20 | * [[Jenkins][ssh]coding连接](https://blog.zhujian.life/posts/6185d82f.html)
21 | * [[Jenkins][github]webhook连接](https://blog.zhujian.life/posts/341b6b1e.html)
22 | * [[Jenkins][Gitlab]webhook连接](https://blog.zhujian.life/posts/6ff96ec3.html)
23 | * Docker
24 | * [在Docker中运行Jenkins](https://blog.zhujian.life/posts/202ee452.html)
25 | * [[Jenkins][GitLab]docker-compose实现](https://blog.zhujian.life/posts/1431c640.html)
26 | * [[Jenkins]使用Docker容器配置编译环境](https://blog.zhujian.life/posts/a260b36c.html)
27 |
28 | ## 常见问题
29 |
30 | - [[Jenkins]反向代理出错](https://blog.zhujian.life/posts/adc5ce0c.html)
31 | - [This Jenkins instance appears to be offline](https://blog.zhujian.life/posts/6af1c833.html)
32 | - [[Jenkins]Url is blocked: Requests to localhost are not allowed](https://blog.zhujian.life/posts/5d46d7f9.html)
33 | - [Hook executed successfully but returned HTTP 404](https://blog.zhujian.life/posts/6ff96ec3.html)
34 | - [Hook executed successfully but returned HTTP 403](https://blog.zhujian.life/posts/6ff96ec3.html)
35 | - [[jenkinsci/blueocean][NodeJS]bash: node: command not found](https://blog.zhujian.life/posts/5d3090aa.html)
36 |
37 | ## 相关阅读
38 |
39 | * [Jenkins](https://jenkins.io/)
40 |
--------------------------------------------------------------------------------
/docs/compose/compose安装.md:
--------------------------------------------------------------------------------
1 |
2 | # Compose安装
3 |
4 | ## 必要条件
5 |
6 | 需要先安装`Docker`,参考[Docker安装](../docker/basic/docker安装.md)
7 |
8 | ## 安装
9 |
10 | 下载`Compose`二进制文件到`/usr/local/bin`
11 |
12 | ```
13 | $ sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
14 | ```
15 |
16 | **从官网上找到上面这一步,获取最新的版本**
17 |
18 | 授予可执行权限
19 |
20 | ```
21 | $ sudo chmod +x /usr/local/bin/docker-compose
22 | ```
23 |
24 | 测试是否安装成功
25 |
26 | ```
27 | $ docker-compose version
28 | docker-compose version 1.24.1, build 4667896b
29 | docker-py version: 3.7.3
30 | CPython version: 3.6.8
31 | OpenSSL version: OpenSSL 1.1.0j 20 Nov 2018
32 | ```
33 |
34 | ## 升级
35 |
36 | 如果正在从`Compose 1.2`或更早升级,删除或迁移升级后的现有容器。这是因为,在第`1.3`版中,`Compose`使用`Docker`标签来跟踪容器,并且需要重新创建容器来添加标签
37 |
38 | 如果`Compose`检测到没有标签创建的容器会拒绝运行。如果想继续使用现有的容器(例如,因为它们拥有要保存的数据卷),可以使用`Compose 1.5.x`以以下命令迁移它们:
39 |
40 | ```
41 | docker-compose migrate-to-labels
42 | ```
43 |
44 | 或者,如果你不担心保存它们,你可以移除它们。`Compose`只是创造新的
45 |
46 | ```
47 | docker container rm -f -v myapp_web_1 myapp_db_1 ...
48 | ```
49 |
50 | ## 卸载
51 |
52 | 如果使用`curl`安装,卸载方式如下:
53 |
54 | ```
55 | sudo rm /usr/local/bin/docker-compose
56 | ```
57 |
58 | 如果使用`pip`安装,卸载方式如下:
59 |
60 | ```
61 | pip uninstall docker-compose
62 | ```
63 |
64 | ### Got a “Permission denied” error?
65 |
66 | 如果使用上述任一方法时出现`Permission denied`错误,则可能没有删除`docker-compose`的适当权限。若要强制删除,将`sudo`置于上述任一命令的前面,然后再次运行
67 |
68 | ## 相关阅读
69 |
70 | * [Install Docker Compose](https://docs.docker.com/compose/install/)
--------------------------------------------------------------------------------
/docs/compose/docker-compose-docker-run.md:
--------------------------------------------------------------------------------
1 |
2 | # 使用docker-compose还是docker run
3 |
4 | 学习了`Docker`和`Docker Compose`,通过`Dockerfile`文件进行镜像的构建,通过`docker-compose.yml`文件进行容器的编排
5 |
6 | 在实际操作过程中,`docker-compose`操作的优点很明显
7 |
8 | 1. 通过`docker-compose.yml`文件配置容器启动选项,结构清晰
9 | 2. 能够实现多容器的管理
10 |
11 | 不过`docker-compose`还在不断更新中,存在不少问题:
12 |
13 | 1. 在`docker-compose.yml`中仅能使用环境变量,无法操作`shell`命令
14 |
15 | 比如获取当前用户信息
16 |
17 | ```
18 | $ id -u
19 | $ id -g
20 | ```
21 |
22 | 2. 在语法版本`3.7`中无法设置`NVIDIA`
23 |
24 | 参考:
25 |
26 | [Support for NVIDIA GPUs under Docker Compose #6691](https://github.com/docker/compose/issues/6691)
27 |
28 | [docker-compose support #1073](https://github.com/NVIDIA/nvidia-docker/issues/1073)
29 |
30 | [NVIDIA Container Toolkit](https://github.com/NVIDIA/nvidia-docker)
31 |
32 | >Please note that this native GPU support has not landed in docker-compose yet. Refer to this issue for discussion.
--------------------------------------------------------------------------------
/docs/compose/imgs/compose-docker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZJDoc/Deploy/005f15ebdba71c6fc4504e55eb95e1abe5163e26/docs/compose/imgs/compose-docker.png
--------------------------------------------------------------------------------
/docs/compose/文件格式-service设置.md:
--------------------------------------------------------------------------------
1 | # 文件格式 - Service设置
2 |
3 | `Service`可以指定一个或多个容器的配置
4 |
5 | ## 指定镜像
6 |
7 | 使用键`image`指定启动容器的镜像
8 |
9 | ```
10 | image: compose:latest
11 | image: compose:0.2.0
12 | ```
13 |
14 | 如果镜像不存在本地,那么`compose`会从远程进行拉取,除非额外设置了`build`键进行构建
15 |
16 | **注意:即使设置了多个,仅会使用最后一个`image`键值对**
17 |
18 | ## 构建镜像
19 |
20 | 使用键`build`指定要构建的镜像:
21 |
22 | 1. `context`:包含`Dockerfile`的目录
23 | 2. `dockerfile`:指定要使用的`Dockerfile`文件路径
24 | 3. `args`:指定构建阶段的参数
25 | 4. `labels`:添加镜像元数据,其作用类似于`LABEL`标签
26 |
27 | 示例如下:
28 |
29 | ```
30 | build:
31 | context: ./dir/
32 | dockerfile: /path/to/Dockerfile-alternate
33 | args:
34 | buildno: 1
35 | gitcommithash: cdc3b19
36 | labels:
37 | - "com.example.description=Accounting webapp"
38 | - "com.example.department=Finance"
39 | - "com.example.label-with-empty-value"
40 | ```
41 |
42 | **注意一:当不需要额外设置,仅指定`context`选项时,可以使用以下方式**
43 |
44 | ```
45 | build: ./dir/
46 | ```
47 |
48 | **注意二:设置构建参数时,需要现在`Dockerfile`文件中指定参数名**
49 |
50 | ```
51 | # Dockerfile
52 | ARG buildno
53 | ARG gitcommithash
54 |
55 | RUN echo "Build number: $buildno"
56 | RUN echo "Based on commit: $gitcommithash"
57 |
58 | # docker-compose
59 | args:
60 | - buildno=1
61 | - gitcommithash=cdc3b19
62 | # 或者
63 | args:
64 | buildno: 1
65 | gitcommithash: cdc3b19
66 | ```
67 |
68 | ## 容器名设置
69 |
70 | ```
71 | container_name: my-web-container
72 | ```
73 |
74 | ## 容器启动设置
75 |
76 | 涉及两个键:`command`和`entrypoint`
77 |
78 | ### 启动命令command
79 |
80 | 重写默认的`COMMAND`命令
81 |
82 | ```
83 | command: bundle exec thin -p 3000
84 | # 或者
85 | command: ["bundle", "exec", "thin", "-p", "3000"]
86 | ```
87 |
88 | ### 入口点程序entrypoint
89 |
90 | 重写`ENTRYPOINT`命令指定的文件
91 |
92 | ```
93 | entrypoint: /code/entrypoint.sh
94 | ```
95 |
96 | ## 环境变量设置
97 |
98 | 涉及两个键: `env_file`和`environment`
99 |
100 | ### 直接添加环境变量
101 |
102 | 使用`environment`可以直接设置环境变量
103 |
104 | ```
105 | environment:
106 | RACK_ENV: development
107 | SHOW: 'true'
108 | SESSION_SECRET:
109 | # 或者
110 | environment:
111 | - RACK_ENV=development
112 | - SHOW=true
113 | - SESSION_SECRET
114 | ```
115 |
116 | ### 使用配置文件
117 |
118 | 使用`env_file`键指定环境变量配置文件(可以指定多个配置文件)
119 |
120 | ```
121 | services:
122 | some-service:
123 | env_file:
124 | - a.env
125 | - b.env
126 | ```
127 |
128 | 配置文件的格式为
129 |
130 | ```
131 | # a.env
132 | VAR=1
133 | # b.env
134 | VAR=hello
135 | ```
136 |
137 | **注意:重复设置的环境变量会被覆盖**
138 |
139 | ## 硬件设备映射
140 |
141 | 使用键`devices`指定容器和主机之间映射的设备
142 |
143 | ```
144 | devices:
145 | - "/dev/ttyUSB0:/dev/ttyUSB0"
146 | ```
147 |
148 | 或者设置`privileged: true`允许容器操作所有主机硬件
149 |
150 | ## 端口设置
151 |
152 | ### 指定内部端口
153 |
154 | 使用键`expose`指定服务内部容器之间开放的端口
155 |
156 | ```
157 | expose:
158 | - "3000"
159 | - "8000"
160 | ```
161 |
162 | ### 指定外部端口
163 |
164 | 使用键`ports`指定主机映射的端口
165 |
166 | * 短格式语法:指定主机和容器端口(`HOST:CONTAINER`)或者仅指定容器端口(主机端口临时设置)
167 |
168 | ```
169 | ports:
170 | - "3000"
171 | - "3000-3005"
172 | - "8000:8000"
173 | - "9090-9091:8080-8081"
174 | - "49100:22"
175 | - "127.0.0.1:8001:8001"
176 | - "127.0.0.1:5000-5010:5000-5010"
177 | - "6060:6060/udp"
178 | ```
179 |
180 | * 长格式语法:...
181 |
182 | ## 添加元数据
183 |
184 | 除了使用`build`进行镜像构建时设置元数据,还可以通过`labels`键设置容器的元数据
185 |
186 | ```
187 | labels:
188 | com.example.description: "Accounting webapp"
189 | com.example.department: "Finance"
190 | com.example.label-with-empty-value: ""
191 | # 或者
192 | labels:
193 | - "com.example.description=Accounting webapp"
194 | - "com.example.department=Finance"
195 | - "com.example.label-with-empty-value"
196 | ```
197 |
198 | ## 重启设置
199 |
200 | 使用键`restart`指定重启设置
201 |
202 | ```
203 | restart: "no" # 默认设置,任何情况下不重启容器
204 | restart: always # 无论哪种情况都要重启
205 | restart: on-failure # 仅在容器启动失败时重启
206 | restart: unless-stopped
207 | ```
208 |
209 | ## 主机名设置
210 |
211 | ```
212 | hostname: foo
213 | ```
214 |
215 | ## 当前用户设置
216 |
217 | ```
218 | user: root
219 | ```
220 |
221 | ## 交互式Shell设置
222 |
223 | 参考:
224 |
225 | [使用Docker Compose的交互式shell](https://www.itranslater.com/qa/details/2131115956192674816)
226 |
227 | [使用Docker Compose的交互式shell?](https://cloud.tencent.com/developer/ask/111359)
228 |
229 | ```
230 | tty: true
231 | stdin_open: true
232 | ```
233 |
234 | ## 相关阅读
235 |
236 | * [Compose file version 3 reference](https://docs.docker.com/compose/compose-file/)
--------------------------------------------------------------------------------
/docs/compose/文件格式-存储设置.md:
--------------------------------------------------------------------------------
1 |
2 | # 文件格式 - 存储设置
3 |
4 | 存储设置分两部分,一是在单个容器上设置,二是设置多容器共用的卷
5 |
6 | ## 单容器存储设置
7 |
8 | 可以为每个容器单独指定和主机的存储设置(*绑定挂载设置或卷设置*),示例如下
9 |
10 | ```
11 | version: "3.7"
12 | services:
13 | web:
14 | image: nginx:alpine
15 | volumes:
16 | - type: volume
17 | source: mydata
18 | target: /data
19 | volume:
20 | nocopy: true
21 | - type: bind
22 | source: ./static
23 | target: /opt/app/static
24 |
25 | db:
26 | image: postgres:latest
27 | volumes:
28 | - "/var/run/postgres/postgres.sock:/var/run/postgres/postgres.sock"
29 | - "dbdata:/var/lib/postgresql/data"
30 |
31 | volumes:
32 | mydata:
33 | dbdata:
34 | ```
35 |
36 | **注意:命名卷必须列在顶级键`volumes`下**
37 |
38 | 有两种语法:
39 |
40 | 1. 短格式语法
41 | 2. 长格式语法
42 |
43 | #### 短格式语法
44 |
45 | 同时指定主机和容器的路径(`HOST:CONTAINER`),还可以添加访问模式(`HOST:CONTAINER:ro`)
46 |
47 | ```
48 | volumes:
49 | # Just specify a path and let the Engine create a volume
50 | - /var/lib/mysql # 仅指定单个路径,会生成一个mysql卷
51 |
52 | # Specify an absolute path mapping
53 | - /opt/data:/var/lib/mysql # 使用绝对路径进行绑定挂载
54 |
55 | # Path on the host, relative to the Compose file
56 | - ./cache:/tmp/cache # 使用相对路径进行绑定挂载
57 |
58 | # User-relative path
59 | - ~/configs:/etc/configs/:ro # 指定访问模式为只读
60 |
61 | # Named volume
62 | - datavolume:/var/lib/mysql # 卷设置
63 | ```
64 |
65 | #### 长格式语法
66 |
67 | ...
68 |
69 | ## 多容器存储设置
70 |
71 | 在顶级键`volumes`可以命名多个卷,在多个容器之间使用
72 |
73 | ```
74 | version: "3.7"
75 |
76 | services:
77 | db:
78 | image: db
79 | volumes:
80 | - data-volume:/var/lib/db
81 | backup:
82 | image: backup-service
83 | volumes:
84 | - data-volume:/var/lib/backup/data
85 |
86 | volumes:
87 | data-volume:
88 | ```
89 |
90 | ### external
91 |
92 | 顶级键`volumes`包含多个属性,`external`属性默认设置为`false`,启动容器时会创建一个命名为`[projectname]_[volumename]`的卷;如果已存在待使用的卷,可以设置`external`属性为`true`,那么启动容器时会直接使用命名为`volumename`的卷。示例如下:
93 |
94 | ```
95 | version: "3.7"
96 |
97 | services:
98 | db:
99 | image: postgres
100 | volumes:
101 | - data:/var/lib/postgresql/data
102 |
103 | volumes:
104 | data:
105 | external: true
106 | ```
107 |
108 | ## 相关阅读
109 |
110 | * [volumes](https://docs.docker.com/compose/compose-file/#volumes)
111 | * [Volume configuration reference](https://docs.docker.com/compose/compose-file/#volume-configuration-reference)
112 | * [docker使用小记6 - docker-compose挂载数据卷出现的问题](https://www.cnblogs.com/qvennnnn/p/11732324.html)
--------------------------------------------------------------------------------
/docs/compose/文件格式概述.md:
--------------------------------------------------------------------------------
1 |
2 | # 文件格式概述
3 |
4 | 之前配置完`Dockerfile`文件后,通过命令进行构建(`build`)和运行(`run`)。除此之外,`docker`提供了工具`docker-compose`来辅助容器编排,通过`docker-compose.yml`文件进行配置
5 |
6 | *`docker-compose`文件格式涉及诸多参数和设置,当前仅学习使用到的功能,之后再逐步更新*
7 |
8 | ## 文件概述
9 |
10 | 示例`docker-compose.yml`文件如下:
11 |
12 | ```
13 | version: "3.7"
14 | services:
15 |
16 | redis:
17 | image: redis:alpine
18 | ports:
19 | - "6379"
20 | networks:
21 | - frontend
22 | deploy:
23 | replicas: 2
24 | update_config:
25 | parallelism: 2
26 | delay: 10s
27 | restart_policy:
28 | condition: on-failure
29 |
30 | db:
31 | image: postgres:9.4
32 | volumes:
33 | - db-data:/var/lib/postgresql/data
34 | networks:
35 | - backend
36 | deploy:
37 | placement:
38 | constraints: [node.role == manager]
39 |
40 | networks:
41 | frontend:
42 | backend:
43 |
44 | volumes:
45 | db-data:
46 | ```
47 |
48 | `compose`文件包含了`4`个顶级键:
49 |
50 | 1. `version`:指定文件规范版本
51 | 2. [services](https://docs.docker.com/compose/compose-file/#service-configuration-reference):指定要操作的容器
52 | 3. [networks](https://docs.docker.com/compose/compose-file/#network-configuration-reference):指定共用的网络配置
53 | 4. [volumes](https://docs.docker.com/compose/compose-file/#volume-configuration-reference):指定共用的存储配置
54 |
55 | 在顶级键下面指定了要配置的章节,在章节下面按`: