赞
踩
一.docker环境
1.在线安装
- ###########centos在线安装#############
- #1.更新yum源
- wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
- yum clean all
- yum makecache
-
- #2.添加docker国内镜像源
- yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
-
- #3.安装docker
- yum -y install docker-ce docker-ce-cli containerd.io
-
-
-
- ##########ubuntu在线安装#########
- apt install -y docker.io

2.离线安装
- #1.自己准备docker离线包,本文自带
- dockerBin.zip
-
- #2.解压移动文件
- unzip dockerBin.zip
- cp ./docker/* /usr/bin/ #启动程序
- cp ./docker/docker.service /etc/systemd/system #开机自启文件,末尾有,第4小节
-
- #3.启动docker、开机自启、查看docker启动状态
- systemctl daemon-reload #重新加载systemctl文件
- systemctl start docker && systemctl enable docker && systemctl status docker
-
-
- #4.docker.service文件如下
- cat docker.service
-
- [Unit]
- Description=Docker Application Container Engine
- Documentation=https://docs.docker.com
- # BindsTo=containerd.service
- After=network-online.target firewalld.service # containerd.service
- Wants=network-online.target
- # Requires=docker.socket
-
- [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
- EnvironmentFile=-/etc/sysconfig/docker
- EnvironmentFile=-/etc/sysconfig/docker-storage
- EnvironmentFile=-/etc/sysconfig/docker-network
- Environment=GOTRACEBACK=crash
-
-
- ExecStart=/usr/bin/dockerd $OPTIONS \
- $DOCKER_STORAGE_OPTIONS \
- $DOCKER_NETWORK_OPTIONS \
- $INSECURE_REGISTRY
- # -H fd:// --containerd=/run/containerd/containerd.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
-
- [Install]
- WantedBy=multi-user.target

3.docker镜像加速配置
- #编写/etc/docker/daemon.json配置文件
- #1.基础版本,完全够用
- tee /etc/docker/daemon.json <<-'EOF'
- {
- "registry-mirrors": ["https://ej3odski.mirror.aliyuncs.com"]
- }
- EOF
-
-
- #2.不理解不要配
- tee /etc/docker/daemon.json <<-'EOF'
- {
- "log-driver": "json-file",
- "log-opts": {
- "max-size": "100m",
- "max-file": "3"
- },
- "exec-opts": ["native.cgroupdriver=systemd"],
- "storage-driver": "overlay2",
- "storage-opts": [
- "overlay2.override_kernel_check=true"
- ],
- "registry-mirrors": [
- "https://docker.mirrors.ustc.edu.cn",
- "https://hub-mirror.c.163.com"
- ]
- }
- EOF
-
- #注意配置文件更新后需要重启docker
- systemctl restart docker

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。