Day0-2. Docker安装部署
2.1 部署环境#
主机名需要按照命名规范配置(后面的部署会用到),没有按照规范做的,会导致后面部署的服务启动失败。
主机名 | 角色 | ip地址 |
---|---|---|
k8s-node6021.k8s.host.com | docker | 10.20.60.21 |
k8s-node6022.k8s.host.com | docker | 10.20.60.22 |
k8s-node6023.k8s.host.com | docker | 10.20.60.23 |
k8s-harbor60200.k8s.host.com | docker | 10.20.60.200 |
注意:这里部署以 k8s-node6021.k8s.host.com
虚机为例,其他几台虚机安装部署方法类似。
2.2 安装Docker#
# step 1: 安装必要的一些系统工具
shell> yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加软件源信息
shell> yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 官方软件源默认启用了最新的软件,安装指定版本的Docker-CE:
# Step 3: 查找Docker-CE的版本:
shell> yum list docker-ce.x86_64 --showduplicates | sort -r
# Step 4: 更新并安装Docker-CE
shell> yum makecache fast
shell> yum -y install docker-ce-18.09.9 docker-ce-cli-18.09.9
2.3 配置Docker#
shell> cat > /etc/docker/daemon.json << "EOF"
{
"oom-score-adjust": -1000,
"registry-mirrors": [
"https://c6ai9izk.mirror.aliyuncs.com",
"https://docker.mirrors.ustc.edu.cn"
],
"data-root":"/export/docker",
"log-driver":"json-file",
"log-opts":{ "max-size" :"100m","max-file":"1"},
"insecure-registries": ["harbor.k8s.91donkey.com"],
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
],
"bip": "169.254.32.1/24",
"live-restore": true,
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
2.4 开启Docker服务#
shell> mkdir -p /export/docker
shell> systemctl enable docker && systemctl start docker
shell> docker version
Client:
Version: 18.09.9
API version: 1.39
Go version: go1.11.13
Git commit: 039a7df9ba
Built: Wed Sep 4 16:51:21 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.9
API version: 1.39 (minimum version 1.12)
Go version: go1.11.13
Git commit: 039a7df
Built: Wed Sep 4 16:22:32 2019
OS/Arch: linux/amd64
Experimental: false
2.5 优化内核参数#
执行下面的命令时会提示 WARNING: bridge-nf-call-iptables is disabled 模块未启用
shell> docker info
...... 内容略 ......
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
- 在
/etc/sysctl.conf
中添加:
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
- 执行
sysctl -p
使配置生效:
shell> sysctl -p
2.6 启动第一个Docker容器#
shell> docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:d58e752213a51785838f9eed2b7a498ffa1cb3aa7f946dda11af39286c3db9a9
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
分类:
Kubernetes
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?