• docker生成ssl证书(按步骤来即可,真实可用)


    ps:ip:xxxx  代表输入ip,ip字样不写

    建议小伙伴多敲一敲

    1、mkdir -pv /etc/docker/certs

    2 、cd /etc/docker/certs

    3、 openssl genrsa -aes256 -out ca-key.pem 4096(生成一个key)

            Enter pass phrase for ca-key.pem:        # 此处输入你想设置的密码

            Verifying - Enter pass phrase for ca-key.pem:  # 再次输入

    4 、openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem

            Enter pass phrase for ca-key.pem:        # 此处输入你想设置的密码

            Verifying - Enter pass phrase for ca-key.pem:  # 再次输入

    5 、openssl genrsa -out server-key.pem 4096

            Enter pass phrase for ca-key.pem:        # 此处输入你想设置的密码

            Verifying - Enter pass phrase for ca-key.pem:  # 再次输入

    6、 openssl req -subj "/CN=ip:xxxx" -sha256 -new -key server-key.pem -out server.csr

            Enter pass phrase for ca-key.pem:        # 此处输入你想设置的密码

            Verifying - Enter pass phrase for ca-key.pem:  # 再次输入

    7、 echo subjectAltName = IP:0.0.0.0,IP:xxxx,IP:127.0.0.1 >> extfile.cnf

    8、 echo extendedKeyUsage = serverAuth >> extfile.cnf

    9、 openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem -extfile extfile.cnf

    10、 openssl genrsa -out key.pem 4096

    11 、openssl req -subj "/CN=ip:xxxx" -new -key key.pem -out client.csr

    12、 echo extendedKeyUsage = clientAuth > extfile-client.cnf

    13、 openssl x509 -req -days 365 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile extfile-client.cnf

    14、 rm -v client.csr server.csr extfile.cnf extfile-client.cnf

    15、 y

    16、 chmod -v 0400 ca-key.pem key.pem server-key.pem

    17、 chmod -v 0444 ca.pem server-cert.pem cert.pem

    18 、vi /lib/systemd/system/docker.service

    [Unit]
    Description=Docker Application Container Engine
    Documentation=https://docs.docker.com
    After=network-online.target firewalld.service containerd.service
    Wants=network-online.target
    Requires=docker.socket containerd.service

    [Service]
    Type=notify
    # the default is not to use systemd for cgroups because the delegate issues still
    # exists and systemd currently does not support the cgroup feature set required
    # for containers run by docker
    ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --tlsverify --tlscacert=/etc/docker/certs/ca.pem --tlscert=/etc/docker/certs/server-cert.pem --tlskey=/etc/docker/certs/server-key.pem -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock
    ExecReload=/bin/kill -s HUP $MAINPID
    TimeoutSec=0
    RestartSec=2
    Restart=always

    # Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
    # Both the old, and new location are accepted by systemd 229 and up, so using the old location
    # to make them work for either version of systemd.
    StartLimitBurst=3

    # Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
    # Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
    # this option work for either version of systemd.
    StartLimitInterval=60s

    # Having non-zero Limit*s causes performance problems due to accounting overhead
    # in the kernel. We recommend using cgroups to do container-local accounting.
    LimitNOFILE=infinity
    LimitNPROC=infinity
    LimitCORE=infinity

    # Comment TasksMax if your systemd version does not support it.
    # Only systemd 226 and above support this option.
    TasksMax=infinity

    # set delegate yes so that systemd does not reset the cgroups of docker containers
    Delegate=yes

    # kill only the docker process, not all processes in the cgroup
    KillMode=process
    OOMScoreAdjust=-500

    [Install]
    WantedBy=multi-user.target

     

    19、 cat /lib/systemd/system/docker.service

    20、 systemctl daemon-reload

    21、 systemctl restart docker

  • 相关阅读:
    书店图书销售管理系统
    【算法-哈希表2】快乐数 和 两数之和
    机器人硬件在环仿真:解决实体开发与测试挑战,提升效率与安全性
    YoloV8改进策略:独家原创,LSKA(大可分离核注意力)改进YoloV8,比Transformer更有效,包括论文翻译和实验结果
    python绘制田字格 青少年电子学会等级考试 中小学生python编程等级考试一级真题答案解析2022年12月
    网络安全专业术语中英对照指南
    Sentinel
    Qt的事件
    阻性负载和感性负载的区别
    Pyinstaller编译python项目为exe遇到的问题,flask服务无法启动
  • 原文地址:https://blog.csdn.net/guochengabcd/article/details/126721239