首页
文章
标签
关于
centos 7.9离线安装docker
发布于: 2023-3-2   更新于: 2023-4-25   未收录
文章字数: 359   阅读时间: 2 分钟   阅读量:

centos 7.9安装docker

1.离线下载docker

https://download.docker.com/linux/static/stable/x86_64/docker-20.10.9.tgz

2.离线安装docker

准备前:

2.0.1 关闭Selinux

首先, 执行getenforce或sestatus, 查询selinux状态, CentOS系统安装后默认为enforcing.

getenforce
或
sestatus

2.0.2 修改selinux配置

1
2
3
4
5
vim /etc/selinux/config
修改selinux配置文件
SELINUX=enforcing
修改为
SELINUX=disabled

2.0.3 重复服务器以上修改生效

1
reboot 

2.1 移动文件到目标服务器并执行tar命令解压,如:

tar -zxvf docker-20.10.9.tgz

2.2 将/home/docker目录下解压出来的所有docker文件复制到 /usr/bin/ 目录下

cp docker/* /usr/bin/

2.3 将docker注册为service,进入/etc/systemd/system/目录,并创建docker.service文件

1
2
cd /etc/systemd/system/
touch docker.service

2.4 编辑docker.service文件,将以下内容复制到docker.service文件中,如下

注1:以下内容中 –insecure-registry=192.168.0.15 此处改为你自己服务器ip。 或者不填写也可以; 注2:以下内容中 -graph /data/docker 是指定docker root路径

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
vi 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=192.168.1.15
#ExecStart=/usr/bin/dockerd  --graph /data/docker -H fd:// --containerd=/run/containerd/containerd.sock

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

2.5 给docker.service文件添加执行权限,如下

1
 chmod 777 /etc/systemd/system/docker.service

2.6 设置docker日志配置

1
2
3
4
5
6
7
8
9
vi /etc/docker/daemon.json

{
	"log-driver": "json-file",
	"log-opts": {
		"max-size": "512m",
		"max-file": "3"
	} 
}

2.7 重新加载配置文件,启动docker并设置开机自启动

1
2
3
systemctl daemon-reload
systemctl start docker
systemctl enable docker.service

2.8 如果非root用户, 安装docker, 还需要将当前用户添加到docker用户组, root用户可以跳过这一步.

// 添加用户组
sudo groupadd docker

sudo usermod -aG docker $USER

// 更新用户组
newgrp docker 

3. 安装docker-compse

3.1 下载二进制文件移动到目标服务器

1
curl -L https://github.com/docker/compose/releases/download/1.24.0-rc3/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

4.查看docker服务运行状态

4.1 查询版本

1
2
3
4
5
docker -v  
docker version 

docker-compose -v
docker-compose version

4.2 查询docker服务

systemctl status docker 

5. docker 配置

docker 配置路径不在路径1就在路径2

5.1 docker 配置路径1

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

5.2 docker 配置路径2

1
/etc/systemd/system/docker.service
kelleygo
随笔记录,为技术沉淀.
目录
相关文章
kubernetes常用命令
1. 将service端口暴露到本地 比如将生产环境的redis暴露到本地6379端口 1 kubectl port-forward service/redis -n [namesplace] 6379:6379 2. 进入容器中 kubectl exec -it [pod] -n [namesplace] -- bash 3. 查看日志 查看最后1行的日志 kubectl logs -f --tail 1 [pod] -n [namesplace] 查看最后一分钟的所有日志 kubectl -n [namesplace] logs [pod] --since=1m 查看指定时间 kubectl -n -n [namesplace] logs -f [pod] --since-time="2022-10-24T02:54:03.467+01:00" 4. 查看配置: kubectl get pod product-6b5c98478b-rpgr6 --namespace=product-prod -o yaml kubectl describe pods product-6b5c98478b-rpgr6 --namespace=product-prod 5.
2023-5-10
ubuntu22.04安装gitlab
1. gitlab安装前准备 系统版本:Ubuntu 22.04.1 LTS 1.1 更新系统环境 sudo apt update sudo apt upgrade 1.2 安装和配置必须的依赖项 1 2 sudo apt-get install -y curl openssh-server ca-certificates tzdata perl sudo apt-get install curl 2.下载和安装gitlab 2.1 下载指定的版本 1 curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash 2.2 开始安装 注意:localhost为访问gitlab的地址,85为访问gitlab的端口号 1 sudo EXTERNAL_URL="http://localhost:85" apt-get install gitlab-ce=15.9.3-ce.0 除非您在安装过程中指定了自定义密码,否则将随机生成一个密码并存储在 /etc/gitlab/initial_root_password文件中(出于安全原因,24 小时后,此文件会被第一次 gitlab-ctl reconfigure 自动删除, 因此若使用随机密码登录,建议安装成功初始登录成功之后,立即修改初始密码)。使用此密码和用户名 root 登录。
2023-4-28
centos7.7手动挂载磁盘分区
1. centos挂载磁盘分区 1.1 系统环境 aliyun CentOS Linux release 7.7.1908 (Core) 1.2 目的: 磁盘扩容到256G,主分区(/dev/vda1)使用100G; 剩156G可扩容 1.3 限制条件: 主分区(/dev/vda1)系统盘使用的是ID 83数据卷分区,主分区(/dev/vda1)默认不是lvm,不能实现无缝扩容, 考虑到生产商用环境数据量大,操作风险大,这里用可分配的156G新建分区挂载到系统磁盘/data目录,而不是在主分区上直接扩容 2. 磁盘分区 2.1 查询磁盘大小 1 2 3 4 5 # lsblk -l NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 253:0 0 256G 0 disk vda1 253:1 0 100G 0 part / vda2 253:2 0 156G 0 part 2.
2023-2-27
windows安装ubuntu22.04
1.安装前准备 U盘>=8G,干净的U盘,因为在安装过程中会清除U盘数据; Windows 7 或更高版本 (32/64 位均可)。 U盘安装引导依赖2选1,建议选Rufus: U盘引导安装依赖uboot - https://github.com/balena-io/etcher/releases/download/v1.18.4/balenaEtcher-Setup-1.18.4.exe U盘引导依赖-Rufus 下载ubuntu镜像选择对应的系统架构版本,建议选择官方,如果下载速度慢则选择aliyun: 官方下载ubuntu22.04桌面版本 阿里云镜像源ubuntu22.04桌面版本 ubuntu-arm架构镜像源 2.U盘制作安装引导 将下载好的rufus和ubuntu22.04镜像放到U盘中 执行rufus二进制文件,按步骤执行: 选择对应的U盘位置 选择ubuntu镜像文件并选择打开 选择START执行写入U盘,可能需要额外的资源来写入ISO,弹窗选择yes;在执行中可能遇到一些警告说会清空U盘,选择OK; 安装引导过程总共需要约10分钟,安装完成后状态栏为READY,此时选择CLOSE,安装完成; 3. 安装ubuntu U盘制作好安装引导后在目标机器上执行: 重启电脑,在启动过程中按F12或者F10或者F2(根据电脑品牌选择不同)进入boot菜单,在菜单中选择USB boot菜单中选择语言,continue进入下一步 安装ubuntu步骤:选择normal installation;如果电脑给的配置很低,就选择minimal installation; 配置安装:install type配置来选择是否将ubuntu作为您唯一的操作系统(此选择会删除windows系统并清除磁盘);如果当前有windows系统则可以选择双系统共同安装; 存储卷LVM选择安全加密,并设置密码 用于恢复数据;密码记录下来保存在其它地方; 创建你的登录账号密码和计算机名字,continue继续 等待进度条,100%完成安装,并选择重启 参考链接 Install Ubuntu desktop bootable引导
2023-2-10
centos7.9扩展磁盘
1. centos 扩展磁盘分区 1.1 系统环境1 vmware centos 7.9 2.扩展步骤 2.1 步骤一 关机状态下在设置->硬盘->扩展->选择硬盘大小; 我这里选择扩展到50G 2.2 步骤二 进入系统内部执行命令扩展磁盘大小,主要是创建逻辑卷(PVC)/物理卷(PV),从逻辑卷(LV)映射到物理卷(PV): 1 2 3 4 5 6 7 8 9 10 11 12 13 df -mh lsblk -l // 查询系统磁盘挂载目录 fdisk -l pvcreate /dev/sda3 vgextend centos /dev/sda3 vgs // 返回卷组的属性 pvdisplay // 查看物理卷 vgdisplay // 查看逻辑卷 lvdisplay // 查看逻辑卷状态 lvextend -L +50G /dev/test_vg/test_lv // 分配指定大小 lvextend -l +100%FREE /dev/centos/root // 分配100的剩余空间 xfs_growfs /dev/mapper/centos-root // 刷新根分区生效 df -mh // 查询磁盘 系统重启更新重新挂载磁盘卷 1 2 3 lvdisplay // 查看逻辑卷状态 vgchange -a y test_vg // 重新激活逻辑卷组 mount /dev/test_vg/test_lv /data // 重新挂载逻辑卷到指定目录 2.
2023-1-2