admin gist felülvizsgálása . Revízióhoz ugrás
1 file changed, 2 insertions
h2.md
@@ -1,3 +1,5 @@ | |||
1 | + | ## 云原生基础设施之容器进阶 | |
2 | + | ||
1 | 3 | 修改镜像源 | |
2 | 4 | 打开终端ssh链接后,首先修改镜像源 | |
3 | 5 | ``` |
admin gist felülvizsgálása . Revízióhoz ugrás
1 file changed, 2 insertions, 2 deletions
h2.md
@@ -10,10 +10,10 @@ vim /etc/docker/daemon.json | |||
10 | 10 | } | |
11 | 11 | ``` | |
12 | 12 | wq保存退出,重启docker | |
13 | - | `` | |
13 | + | ``` | |
14 | 14 | systemctl daemon-reload | |
15 | 15 | systemctl restart docker | |
16 | - | `` | |
16 | + | ``` | |
17 | 17 | 实验一 | |
18 | 18 | 1. 拉取progrium/stress压力测试镜像 | |
19 | 19 | ``` |
admin gist felülvizsgálása . Revízióhoz ugrás
1 file changed, 1 insertion, 1 deletion
h2.md
@@ -29,7 +29,7 @@ docker run -d --name my_stress --cpu-period=100000 --cpu-quota=70000 progrium/st | |||
29 | 29 | top | |
30 | 30 | ``` | |
31 | 31 | ||
32 | - | # 4. 进入目录,查看限制值为70000(考点) | |
32 | + | 4. 进入目录,查看限制值为70000(考点) | |
33 | 33 | ``` | |
34 | 34 | cd /sys/fs/cgroup/cpu/docker/容器ID/ | |
35 | 35 | cat cpu.cfs_quota_us |
admin gist felülvizsgálása . Revízióhoz ugrás
1 file changed, 44 insertions, 5 deletions
h2.md
@@ -1,6 +1,6 @@ | |||
1 | 1 | 修改镜像源 | |
2 | 2 | 打开终端ssh链接后,首先修改镜像源 | |
3 | - | ||
3 | + | ``` | |
4 | 4 | vim /etc/docker/daemon.json | |
5 | 5 | ||
6 | 6 | { | |
@@ -8,70 +8,109 @@ vim /etc/docker/daemon.json | |||
8 | 8 | "https://docker.1panel.live" | |
9 | 9 | ] | |
10 | 10 | } | |
11 | + | ``` | |
11 | 12 | wq保存退出,重启docker | |
12 | - | ||
13 | + | `` | |
13 | 14 | systemctl daemon-reload | |
14 | 15 | systemctl restart docker | |
16 | + | `` | |
15 | 17 | 实验一 | |
16 | - | # 1. 拉取progrium/stress压力测试镜像 | |
18 | + | 1. 拉取progrium/stress压力测试镜像 | |
19 | + | ``` | |
17 | 20 | docker pull progrium/stress | |
18 | - | ||
21 | + | ``` | |
19 | 22 | 2. 运行容器 | |
23 | + | ``` | |
20 | 24 | docker run -d --name my_stress --cpu-period=100000 --cpu-quota=70000 progrium/stress --cpu 1 | |
25 | + | ``` | |
21 | 26 | ||
22 | 27 | 3. 通过top命令验证容器cpu使用率在70% | |
28 | + | ``` | |
23 | 29 | top | |
30 | + | ``` | |
24 | 31 | ||
25 | 32 | # 4. 进入目录,查看限制值为70000(考点) | |
33 | + | ``` | |
26 | 34 | cd /sys/fs/cgroup/cpu/docker/容器ID/ | |
27 | 35 | cat cpu.cfs_quota_us | |
28 | 36 | cat cpu.cfs_quota_us | |
29 | 37 | cat cpu.cfs_quota_us | |
30 | 38 | cat cpu.cfs_quota_us | |
31 | 39 | cat cpu.cfs_quota_us | |
40 | + | ``` | |
32 | 41 | 实验二 | |
33 | 42 | 0.拉取centos镜像 | |
43 | + | ``` | |
34 | 44 | docker pull centos | |
45 | + | ``` | |
35 | 46 | 1. 创建网络 | |
47 | + | ``` | |
36 | 48 | docker network create --driver bridge --subnet 173.18.0.0/16 --gateway 173.18.0.1 my-bridge-network | |
49 | + | ``` | |
37 | 50 | ||
38 | 51 | 2. 运行容器1 | |
52 | + | ``` | |
39 | 53 | docker run -d --name centos1 --network my-bridge-network centos:latest /bin/sh -c "while true; do sleep 1; done" | |
54 | + | ``` | |
40 | 55 | ||
41 | 56 | 2. 运行容器2 | |
57 | + | ``` | |
42 | 58 | docker run -d --name centos2 --network my-bridge-network centos:latest /bin/sh -c "while true; do sleep 1; done" | |
59 | + | ``` | |
43 | 60 | ||
44 | 61 | 3. 进入容器2 | |
62 | + | ``` | |
45 | 63 | docker exec -it centos2 bash | |
64 | + | ``` | |
46 | 65 | ||
47 | 66 | 4. ping容器1的ip,多ping几次 | |
67 | + | ``` | |
48 | 68 | ping 173.18.0.2 | |
69 | + | ``` | |
49 | 70 | ||
50 | 71 | 5. ping通即可(考点) | |
51 | 72 | 实验三 | |
52 | 73 | 1. 创建一个 Docker volume: | |
74 | + | ``` | |
53 | 75 | docker volume create my_volume | |
76 | + | ``` | |
54 | 77 | ||
55 | 78 | 2. 创建并运行一个挂载 volume 的 CentOS 容器 | |
79 | + | ``` | |
56 | 80 | docker run -it --name centos3 -v my_volume:/data centos:latest /bin/bash | |
81 | + | ``` | |
57 | 82 | ||
58 | 83 | 3. 在容器中写入文件 | |
84 | + | ``` | |
59 | 85 | echo "this is page from docker managed volume." > /data/index.html | |
86 | + | ``` | |
60 | 87 | ||
61 | 88 | 4. 退出容器 | |
89 | + | ``` | |
62 | 90 | exit | |
91 | + | ``` | |
63 | 92 | ||
64 | 93 | 5. 删除容器 | |
94 | + | ``` | |
65 | 95 | docker rm -f centos3 | |
96 | + | ``` | |
66 | 97 | ||
67 | 98 | 6. 获取 volume 挂载路径 | |
99 | + | ``` | |
68 | 100 | docker volume inspect my_volume | |
101 | + | ``` | |
69 | 102 | ||
70 | 103 | 7. 进入路径 | |
104 | + | ``` | |
71 | 105 | cd /var/lib/docker/volumes/my_volume/_data/ | |
106 | + | ``` | |
72 | 107 | ||
73 | 108 | 8. 验证文件内容 | |
109 | + | ``` | |
74 | 110 | cat index.html | |
111 | + | ``` | |
75 | 112 | ||
76 | 113 | 9. 内容如下即可(考点) | |
77 | - | this is page from docker managed volume. | |
114 | + | ``` | |
115 | + | this is page from docker managed volume. | |
116 | + | ``` |
admin gist felülvizsgálása . Revízióhoz ugrás
1 file changed, 18 insertions, 18 deletions
h2.md
@@ -16,10 +16,10 @@ systemctl restart docker | |||
16 | 16 | # 1. 拉取progrium/stress压力测试镜像 | |
17 | 17 | docker pull progrium/stress | |
18 | 18 | ||
19 | - | # 2. 运行容器 | |
19 | + | 2. 运行容器 | |
20 | 20 | docker run -d --name my_stress --cpu-period=100000 --cpu-quota=70000 progrium/stress --cpu 1 | |
21 | 21 | ||
22 | - | # 3. 通过top命令验证容器cpu使用率在70% | |
22 | + | 3. 通过top命令验证容器cpu使用率在70% | |
23 | 23 | top | |
24 | 24 | ||
25 | 25 | # 4. 进入目录,查看限制值为70000(考点) | |
@@ -30,48 +30,48 @@ cat cpu.cfs_quota_us | |||
30 | 30 | cat cpu.cfs_quota_us | |
31 | 31 | cat cpu.cfs_quota_us | |
32 | 32 | 实验二 | |
33 | - | # 0.拉取centos镜像 | |
33 | + | 0.拉取centos镜像 | |
34 | 34 | docker pull centos | |
35 | - | # 1. 创建网络 | |
35 | + | 1. 创建网络 | |
36 | 36 | docker network create --driver bridge --subnet 173.18.0.0/16 --gateway 173.18.0.1 my-bridge-network | |
37 | 37 | ||
38 | - | # 2. 运行容器1 | |
38 | + | 2. 运行容器1 | |
39 | 39 | docker run -d --name centos1 --network my-bridge-network centos:latest /bin/sh -c "while true; do sleep 1; done" | |
40 | 40 | ||
41 | - | # 2. 运行容器2 | |
41 | + | 2. 运行容器2 | |
42 | 42 | docker run -d --name centos2 --network my-bridge-network centos:latest /bin/sh -c "while true; do sleep 1; done" | |
43 | 43 | ||
44 | - | # 3. 进入容器2 | |
44 | + | 3. 进入容器2 | |
45 | 45 | docker exec -it centos2 bash | |
46 | 46 | ||
47 | - | # 4. ping容器1的ip,多ping几次 | |
47 | + | 4. ping容器1的ip,多ping几次 | |
48 | 48 | ping 173.18.0.2 | |
49 | 49 | ||
50 | - | # 5. ping通即可(考点) | |
50 | + | 5. ping通即可(考点) | |
51 | 51 | 实验三 | |
52 | - | # 1. 创建一个 Docker volume: | |
52 | + | 1. 创建一个 Docker volume: | |
53 | 53 | docker volume create my_volume | |
54 | 54 | ||
55 | - | # 2. 创建并运行一个挂载 volume 的 CentOS 容器 | |
55 | + | 2. 创建并运行一个挂载 volume 的 CentOS 容器 | |
56 | 56 | docker run -it --name centos3 -v my_volume:/data centos:latest /bin/bash | |
57 | 57 | ||
58 | - | # 3. 在容器中写入文件 | |
58 | + | 3. 在容器中写入文件 | |
59 | 59 | echo "this is page from docker managed volume." > /data/index.html | |
60 | 60 | ||
61 | - | # 4. 退出容器 | |
61 | + | 4. 退出容器 | |
62 | 62 | exit | |
63 | 63 | ||
64 | - | # 5. 删除容器 | |
64 | + | 5. 删除容器 | |
65 | 65 | docker rm -f centos3 | |
66 | 66 | ||
67 | - | # 6. 获取 volume 挂载路径 | |
67 | + | 6. 获取 volume 挂载路径 | |
68 | 68 | docker volume inspect my_volume | |
69 | 69 | ||
70 | - | # 7. 进入路径 | |
70 | + | 7. 进入路径 | |
71 | 71 | cd /var/lib/docker/volumes/my_volume/_data/ | |
72 | 72 | ||
73 | - | # 8. 验证文件内容 | |
73 | + | 8. 验证文件内容 | |
74 | 74 | cat index.html | |
75 | 75 | ||
76 | - | # 9. 内容如下即可(考点) | |
76 | + | 9. 内容如下即可(考点) | |
77 | 77 | this is page from docker managed volume. |
admin gist felülvizsgálása . Revízióhoz ugrás
1 file changed, 77 insertions
h2.md(fájl létrehozva)
@@ -0,0 +1,77 @@ | |||
1 | + | 修改镜像源 | |
2 | + | 打开终端ssh链接后,首先修改镜像源 | |
3 | + | ||
4 | + | vim /etc/docker/daemon.json | |
5 | + | ||
6 | + | { | |
7 | + | "registry-mirrors": [ | |
8 | + | "https://docker.1panel.live" | |
9 | + | ] | |
10 | + | } | |
11 | + | wq保存退出,重启docker | |
12 | + | ||
13 | + | systemctl daemon-reload | |
14 | + | systemctl restart docker | |
15 | + | 实验一 | |
16 | + | # 1. 拉取progrium/stress压力测试镜像 | |
17 | + | docker pull progrium/stress | |
18 | + | ||
19 | + | # 2. 运行容器 | |
20 | + | docker run -d --name my_stress --cpu-period=100000 --cpu-quota=70000 progrium/stress --cpu 1 | |
21 | + | ||
22 | + | # 3. 通过top命令验证容器cpu使用率在70% | |
23 | + | top | |
24 | + | ||
25 | + | # 4. 进入目录,查看限制值为70000(考点) | |
26 | + | cd /sys/fs/cgroup/cpu/docker/容器ID/ | |
27 | + | cat cpu.cfs_quota_us | |
28 | + | cat cpu.cfs_quota_us | |
29 | + | cat cpu.cfs_quota_us | |
30 | + | cat cpu.cfs_quota_us | |
31 | + | cat cpu.cfs_quota_us | |
32 | + | 实验二 | |
33 | + | # 0.拉取centos镜像 | |
34 | + | docker pull centos | |
35 | + | # 1. 创建网络 | |
36 | + | docker network create --driver bridge --subnet 173.18.0.0/16 --gateway 173.18.0.1 my-bridge-network | |
37 | + | ||
38 | + | # 2. 运行容器1 | |
39 | + | docker run -d --name centos1 --network my-bridge-network centos:latest /bin/sh -c "while true; do sleep 1; done" | |
40 | + | ||
41 | + | # 2. 运行容器2 | |
42 | + | docker run -d --name centos2 --network my-bridge-network centos:latest /bin/sh -c "while true; do sleep 1; done" | |
43 | + | ||
44 | + | # 3. 进入容器2 | |
45 | + | docker exec -it centos2 bash | |
46 | + | ||
47 | + | # 4. ping容器1的ip,多ping几次 | |
48 | + | ping 173.18.0.2 | |
49 | + | ||
50 | + | # 5. ping通即可(考点) | |
51 | + | 实验三 | |
52 | + | # 1. 创建一个 Docker volume: | |
53 | + | docker volume create my_volume | |
54 | + | ||
55 | + | # 2. 创建并运行一个挂载 volume 的 CentOS 容器 | |
56 | + | docker run -it --name centos3 -v my_volume:/data centos:latest /bin/bash | |
57 | + | ||
58 | + | # 3. 在容器中写入文件 | |
59 | + | echo "this is page from docker managed volume." > /data/index.html | |
60 | + | ||
61 | + | # 4. 退出容器 | |
62 | + | exit | |
63 | + | ||
64 | + | # 5. 删除容器 | |
65 | + | docker rm -f centos3 | |
66 | + | ||
67 | + | # 6. 获取 volume 挂载路径 | |
68 | + | docker volume inspect my_volume | |
69 | + | ||
70 | + | # 7. 进入路径 | |
71 | + | cd /var/lib/docker/volumes/my_volume/_data/ | |
72 | + | ||
73 | + | # 8. 验证文件内容 | |
74 | + | cat index.html | |
75 | + | ||
76 | + | # 9. 内容如下即可(考点) | |
77 | + | this is page from docker managed volume. |