docker和docker-compose安装

docker安装

1.docker安装包下载:docker-29.0.0.tgz

下载网址:https://download.docker.com/linux/static/stable/x86_64/

把软件包解压到/usr/bin/目录

tar -zxvf docker-29.0.0.tgz

cp ./docker/* /usr/bin/

2.在/etc/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 --selinux-enabled=false --insecure-registry=10.1.1.1

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=1048576

LimitNPROC=1048576

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

文件赋权可执行

chmod +x /etc/systemd/system/docker.service

3.设置docker启动参数

[root@jy-k8s-master01 ~]# cat /etc/docker/daemon.json

{

#镜像加速配置

"registry-mirrors": [

"https://docker.mirrors.ustc.edu.cn",

"https://reg-mirror.qiniu.com",

"https://hub-mirror.c.163.com",

"http://10.66.193.7:8082"

],

#绑定端口

"hosts": ["tcp://0.0.0.0:2376", "unix:///var/run/docker.sock"],

#docker默认用https,加入配置项后可以http了

"insecure-registries": ["10.66.193.7:8082","10.66.193.7:8083","registry.kubeoperator.io:8083","registry.kubeoperator.io:8082","172.16.0.0/16","192.168.0.0/16"],

"max-concurrent-downloads": 10,

"log-driver": "json-file",

"log-level": "warn",

"log-opts": {

"max-size": "10m",

"max-file": "3"

},

#设置为true,表示在Docker守护进程重新启动时,容器将继续运行,而不会被停止

"live-restore": true,

"bip": "172.17.0.1/16",

#数据存储目录

"data-root": "/var/lib/docker",

"exec-opts": ["native.cgroupdriver=systemd"]

}

4.启动docker

systemctl daemon-reload

systemctl start docker

systemctl enable docker.service

5.查看docker版本

docker -v

1762916389426_F1AA67A2-3546-4f9f-BEEB-85322888AA83

docker-compose安装

1.下载

网址:https://github.com/docker/compose/releases/

赋权

chmod +x docker-compose

mv docker-compose /usr/bin/

2.查看版本

docker-compose version

1762916356707_567C4323-CBAA-4b83-B178-0F2D34E39BD7

posted @ 2025-11-20 17:31  小蓝莓  阅读(9)  评论(0)    收藏  举报