二进制部署docker

11

1下载docker二进制文件 

 

https://download.docker.com/linux/static/stable/x86_64/



2解压tar包



tar xf docker-20.10.0.tgz



3解压缩完成后将docker目录中的所有文件复制至/usr/bin/目录下



 cp docker/* /usr/bin


4 配置docker.service文件


 vim /usr/lib/systemd/system/docker.service

[Unit]

Description=Docker Application Container Engine

Documentation=https://docs.docker.com

After=network-online.target firewalld.service

Wants=network-online.target

[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

ExecReload=/bin/kill -s HUP $MAINPID

# 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

# Uncomment TasksMax if your systemd version supports it.

# Only systemd 226 and above support this version.

#TasksMax=infinity

TimeoutStartSec=0

# 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

# restart the docker process if it exits prematurely

Restart=on-failure

StartLimitBurst=3

StartLimitInterval=60s

[Install]

WantedBy=multi-user.target


5daemon.json说明

{

    "api-cors-header": "",

    "authorization-plugins": [ ],

    "bip": "",

    "bridge": "",

    "cgroup-parent": "",

    "cluster-store": "",

    "cluster-store-opts": { },

    "cluster-advertise": "",

    "debug": true,            # 启用debug的模式,启用后,可以看到很多的启动信息,默认false

    "default-gateway": "",

    "default-gateway-v6": "",

    "default-runtime": "runc",

    "default-ulimits": { },

    "disable-legacy-registry": false,

    "dns": ["192.168.1.1"],  # 设定容器DNS的地址,在容器的 /etc/resolv.conf文件中可查看

    "dns-opts": [ ],        # 容器 /etc/resolv.conf 文件,其他设置

    "dns-search": [ ],      # 设定容器的搜索域,当设定搜索域为 .example.com 时,在搜索一个名为 host 的 主机时,DNS不仅搜索host,还会搜索host.example.com 。 注意:如果不设置, Docker 会默认用主机上的 /etc/resolv.conf 来配置容器

    "exec-opts": [ ],

    "exec-root": "",

    "fixed-cidr": "",

    "fixed-cidr-v6": "",

    "graph": "/var/lib/docker",      # 已废弃,使用data-root代替,这个主要看docker的版本

    "data-root": "/var/lib/docker",  # Docker运行时使用的根路径,默认/var/lib/docker

    "group": "",                    # Unix套接字的属组,仅指/var/run/docker.sock

    "hosts": [ ],                    # 设置容器hosts

    "icc": false,

    "insecure-registries": [ ],      # 配置docker的私库地址

    "ip": "0.0.0.0",

    "iptables": false,

    "ipv6": false,

    "ip-forward": false,  # 默认true, 启用 net.ipv4.ip_forward ,进入容器后使用 sysctl -a | grepnet.ipv4.ip_forward 查看

    "ip-masq": false,

    "labels": ["nodeName=node-121"],  # docker主机的标签,很实用的功能,例如定义:–label nodeName=host-121

    "live-restore": true,

    "log-driver": "",

    "log-level": "",

    "log-opts": { },

    "max-concurrent-downloads": 3,

    "max-concurrent-uploads": 5,

    "mtu": 0,

    "oom-score-adjust": -500,

    "pidfile": "",    # Docker守护进程的PID文件

    "raw-logs": false,

    "registry-mirrors": ["xxxx"],  # 镜像加速的地址,增加后在 docker info中可查看

    "runtimes": {

        "runc": {

            "path": "runc"

        },

        "custom": {

            "path": "/usr/local/bin/my-runc-replacement",

            "runtimeArgs": [

                "--debug"

            ]

        }

    },

    "selinux-enabled": false,  # 默认 false,启用selinux支持

    "storage-driver": "",

    "storage-opts": [ ],

    "swarm-default-advertise-addr": "",

    "tls": true,      # 默认false, 启动TLS认证开关

    "tlscacert": "",  # 默认~/.docker/ca.pem,通过CA认证过的的certificate文件路径

    "tlscert": "",    # 默认~/.docker/cert.pem,TLS的certificate文件路径

    "tlskey": "",      # 默认~/.docker/key.pem,TLS的key文件路径

    "tlsverify": true, # 默认false,使用TLS并做后台进程与客户端通讯的验证

    "userland-proxy": false,

    "userns-remap": ""

}



6daemon.json 样例


cat  /etc/docker/daemon.json

{

  "registry-mirrors": ["https://bjjtv7cs.mirror.aliyuncs.com"],

   "insecure-registries": ["172.176.17.1:5000"]

}



7启动docker 



systemctl daemon-reload

systemctl enable --now dockeer