Docker基础Part2——基本命令

[TOC]

帮助命令

1
2
3
docker version  # 版本信息
docker info # 系统信息,包括镜像、容器、运行状态、插件
docker 命令 --help

帮助文档 https://docs.docker.com/reference/

镜像命令

注意这里是镜像,不是容器。

docker images

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@VM-1-14-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest d1165f221234 6 weeks ago 13.3kB

# 解释
REPOSITORY:镜像的仓库源
TAG:镜像的标签
IMAGE ID:镜像ID
CREATED:镜像创建时间
SIZE:镜像大小

# 可选项
-a, --all # 列出所有镜像
-q, --quiet # 只显示镜像
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@VM-1-14-centos ~]# docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 10777 [OK]
mariadb MariaDB Server is a high performing open sou… 4058 [OK]
......

# 可选项
-f, --filter filter Filter output based on conditions provided
--format string Pretty-print search using a Go template
--limit int Max number of search results (default 25)
--no-trunc Don't truncate output

# demo
docker search mysql --filter=STARS=3000 # 只显示stars>=3k的

docker pull

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
38
39
40
41
42
43
44
45
46
[root@VM-1-14-centos ~]# docker pull mysql
Using default tag: latest # 不指定tag则默认latest
latest: Pulling from library/mysql
f7ec5a41d630: Pull complete # 分层下载是docker的核心,联合文件系统
9444bb562699: Pull complete
6a4207b96940: Pull complete
181cefd361ce: Pull complete
8a2090759d8a: Pull complete
15f235e0d7ee: Pull complete
d870539cd9db: Pull complete
493aaa84617a: Pull complete
bfc0e534fc78: Pull complete
fae20d253f9d: Pull complete
9350664305b3: Pull complete
e47da95a5aab: Pull complete
Digest: sha256:04ee7141256e83797ea4a84a4d31b1f1bc10111c8d1bc1879d52729ccd19e20a # 签名
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest # 真实地址

# 两者等价
docker pull mysql
docker pull docker.io/library/mysql:latest

# 指定版本下载(一定要来源于官方支持的版本)
[root@VM-1-14-centos ~]# docker pull mysql:5.7
5.7: Pulling from library/mysql
f7ec5a41d630: Already exists # 已存在的部分分层文件可以共用,不需要重复下载
9444bb562699: Already exists
6a4207b96940: Already exists
181cefd361ce: Already exists
8a2090759d8a: Already exists
15f235e0d7ee: Already exists
d870539cd9db: Already exists
cb7af63cbefa: Pull complete # 只需要更新不同的文件
151f1721bdbf: Pull complete
fcd19c3dd488: Pull complete
415af2aa5ddc: Pull complete
Digest: sha256:a655529fdfcbaf0ef28984d68a3e21778e061c886ff458b677391924f62fb457
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7

# 可选项
-a, --all-tags Download all tagged images in the repository
--disable-content-trust Skip image verification (default true)
--platform string Set platform if server is multi-platform capable
-q, --quiet Suppress verbose output

docker rmi

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@VM-1-14-centos ~]# docker rmi -f 87eca374c0ed
Untagged: mysql:5.7
Untagged: mysql@sha256:a655529fdfcbaf0ef28984d68a3e21778e061c886ff458b677391924f62fb457
Deleted: sha256:87eca374c0ed97f0f0b504174b0d22b0a0add454414c0dbf5ae43870369f6854 # 只删除了5.7部分
Deleted: sha256:3b035442a2f8d52d6c5c2d83a18c6c21a89b4dc6c89b481bcf40df89087655ce
Deleted: sha256:a223f1762b2c619a59b81fc2304bf4c9b791c777c8bdb19760c09cbd1f061efc
Deleted: sha256:92402939b3fd03bee3745eb90df9799bcb7d0ef92ca8ecf7ef37ad9c8a550084
Deleted: sha256:028b21e33aa4cd9c88acdd194d5cbef25638ffbca8669bfc0da72ad1eb148997

# rmi中i表示image
# -f全部删除
# 可以通过镜像的名字或者id删

# 删除多个/所有镜像
[root@VM-1-14-centos ~]# docker rmi -f $(docker images -aq)

容器命令

启动容器

1
2
3
4
5
6
7
8
9
10
11
12
docker run [ option ] image

# 参数说明
-name="Name" # 容器名字
-d # 后台方式运行
-it # 使用交互方式运行,进入容器查看内容
-p # 指定容器端口 -p 8080:8080
-p ip:主机端口:容器端口
-p 主机端口:容器端口 # 常用,将主机端口映射到容器端口
-p 容器端口 # 内部使用
容器端口
-P # 随机指定端口

每次run都是新建一个容器!

demo

1
2
3
4
5
6
7
8
9
10
11
12
13
# 在 linux 上下载 centos 镜像,启动并进入容器
# 使用 /bin/bash 或 /bin/sh 启用控制台命令交互
# 此处主机名 33a022c1918a 就是容器id
# 此时这个容器内部就是一个centos系统,但是很多地方不完善
# exit退出镜像回到主机
[root@VM-1-14-centos ~]# docker pull centos
[root@VM-1-14-centos ~]# docker run -it centos /bin/bash
[root@33a022c1918a /]# ls
bin dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var
[root@33a022c1918a /]# exit
exit
[root@VM-1-14-centos ~]# ls /
bin boot data dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var

查看容器

1
2
3
4
5
6
docker ps [ options ]

Options:
-a, --all # 列出当前正在运行(默认)+历史运行过的容器
-n, --last int # 最近n个创建过的容器
-q, --quiet # 只显示id

demo

1
2
3
4
5
6
7
8
9
10
11
12
[root@VM-1-14-centos ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-1-14-centos ~]# docker ps -all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
33a022c1918a centos "/bin/bash" 13 minutes ago Exited (127) 9 minutes ago nostalgic_hermann
[root@VM-1-14-centos ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
33a022c1918a centos "/bin/bash" 14 minutes ago Exited (127) 9 minutes ago nostalgic_hermann
d036353864f6 d1165f221234 "/hello" 2 days ago Exited (0) 2 days ago cranky_nash
[root@VM-1-14-centos ~]# docker ps -aq
33a022c1918a
d036353864f6

退出容器

1
2
exit  # 退出并停止容器运行
ctrl+P+Q # 退出但不停止

删除容器

1
2
3
docker rm 容器id  # 删除指定的容器,不能删除正在运行的容器,除非 rm -f
docker rm -f $(docker ps -aq) # 删除所有容器
docker ps -aq | xargs docker rm # 删除所有容器

启动/停止容器

1
2
3
4
docker start 容器id  # 启动
docker restart 容器id # 重启
docker stop 容器id # 停止
docker kill 容器id # 强制停止

其他命令

后台启动容器

1
2
3
4
5
6
# docker run -d 镜像
[root@VM-1-14-centos ~]# docker run -d centos
9dfce832258f344250b3ad0ddaed6e55a9e4ae711a558bb5083dcf9162dd551b

# 虽然创建了容器后台运行,但是没有检测到前台应用进程,所以自动停止了。
# 例如:Nginx容器启动之后,发现自己没有提供服务,就立刻停止

查看日志

1
2
3
4
5
6
7
8
9
docker logs

Options:
--details Show extra details provided to logs
-f, --follow Follow log output
--since string Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)
-n, --tail string Number of lines to show from the end of the logs (default "all")
-t, --timestamps Show timestamps
--until string Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)

demo

1
2
3
4
5
6
7
8
[root@VM-1-14-centos ~]# docker run -d centos /bin/bash -c "while true;do echo NephrenCake;sleep 1;done"
[root@VM-1-14-centos ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
813d27116121 centos "/bin/bash -c 'while…" 7 minutes ago Up 7 minutes peaceful_gag
[root@VM-1-14-centos ~]# docker logs -f -t --tail 5 813d27116121
2021-04-23T06:18:08.137574755Z NephrenCake
...... # ctrl + c 退出
[root@VM-1-14-centos ~]# docker stop 813d27116121

查看容器中进程信息

1
docker top 进程id

demo

1
2
3
4
5
6
7
8
9
[root@VM-1-14-centos ~]# docker restart 813d27116121
813d27116121
[root@VM-1-14-centos ~]# docker logs -ft --tail 5 813d27116121
2021-04-23T06:38:02.133138721Z NephrenCake
...... # restart重新启动,依然执行之前的命令
[root@VM-1-14-centos ~]# docker top 813d27116121
UID PID PPID C STIME TTY TIME CMD
root 11818 11796 0 14:38 ? 00:00:00 /bin/bash -c while true;do echo NephrenCake;sleep 1;done
root 11935 11818 0 14:38 ? 00:00:00 /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 1

查看镜像的元数据

1
2
3
4
5
6
docker inspect [ options ] 容器id

Options:
-f, --format string Format the output using the given Go template
-s, --size Display total file sizes if the type is container
--type string Return JSON for specified type

demo

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# 容器的元数据================================================================================================
[root@VM-1-14-centos ~]# docker inspect 813d27116121
[
{
"Id": "813d2711612126bdc63c81b30d29f11894f4d51a179749e33b1500e917b56b38", # 使用的id只是全id的缩写
"Created": "2021-04-23T06:09:40.625524708Z", # 创建时间
"Path": "/bin/bash", # 控制台目录
"Args": [ # 传递的参数
"-c",
"while true;do echo NephrenCake;sleep 1;done"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 11818, # 父进程id
"ExitCode": 0,
"Error": "",
"StartedAt": "2021-04-23T06:38:02.136315705Z",
"FinishedAt": "2021-04-23T06:23:18.602040203Z"
},
"Image": "sha256:300e315adb2f96afe5f0b2780b87f28ae95231fe3bdd1e16b9ba606307728f55", # 镜像源
"ResolvConfPath": "/var/lib/docker/containers/813d2711612126bdc63c81b30d29f11894f4d51a179749e33b1500e917b56b38/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/813d2711612126bdc63c81b30d29f11894f4d51a179749e33b1500e917b56b38/hostname",
"HostsPath": "/var/lib/docker/containers/813d2711612126bdc63c81b30d29f11894f4d51a179749e33b1500e917b56b38/hosts",
"LogPath": "/var/lib/docker/containers/813d2711612126bdc63c81b30d29f11894f4d51a179749e33b1500e917b56b38/813d2711612126bdc63c81b30d29f11894f4d51a179749e33b1500e917b56b38-json.log",
"Name": "/peaceful_gagarin",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": { # 主机配置
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "host",
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/b6d0d37faec7c071970c4880b019ff1d55f117ef18406c988b813f302bb227d0-init/diff:/var/lib/docker/overlay2/e7f999e147eaa9cc6658059fe0a66e6f6bca79957c99cf69bfe563b82bcbd2be/diff",
"MergedDir": "/var/lib/docker/overlay2/b6d0d37faec7c071970c4880b019ff1d55f117ef18406c988b813f302bb227d0/merged",
"UpperDir": "/var/lib/docker/overlay2/b6d0d37faec7c071970c4880b019ff1d55f117ef18406c988b813f302bb227d0/diff",
"WorkDir": "/var/lib/docker/overlay2/b6d0d37faec7c071970c4880b019ff1d55f117ef18406c988b813f302bb227d0/work"
},
"Name": "overlay2"
},
"Mounts": [ # 挂载
{
"Type": "bind",
"Source": "/home/volume", # 主机内目录
"Destination": "/home", # 容器内目录,目标地址
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "813d27116121", # 容器名
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [ # 环境变量
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [ # command命令行命令
"/bin/bash",
"-c",
"while true;do echo NephrenCake;sleep 1;done"
],
"Image": "centos",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"org.label-schema.build-date": "20201204",
"org.label-schema.license": "GPLv2",
"org.label-schema.name": "CentOS Base Image",
"org.label-schema.schema-version": "1.0",
"org.label-schema.vendor": "CentOS"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "a58ab6299e5a5cb4b40068484267752f8958795d9073e2bf70ad47478cfd76e3",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/a58ab6299e5a",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "8b66ea3b5e36bc2599ef8f9f8423036daec31b9df332ba6a9a6924125c3770d9",
"Gateway": "172.18.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.18.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:12:00:03",
"Networks": { # docker网络
"bridge": { # 桥接网卡
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "c49bd3c9074eccb131f580ae87a0f639459d8fbfb6106ff16d95de982f955cb6",
"EndpointID": "8b66ea3b5e36bc2599ef8f9f8423036daec31b9df332ba6a9a6924125c3770d9",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:03",
"DriverOpts": null
}
}
}
}
]

# 镜像的元数据================================================================================================
[root@VM-1-14-centos ~]# docker image inspect centos
[
{
"Id": "sha256:300e315adb2f96afe5f0b2780b87f28ae95231fe3bdd1e16b9ba606307728f55",
"RepoTags": [
"centos:latest"
],
"RepoDigests": [
"centos@sha256:5528e8b1b1719d34604c87e11dcd1c0a20bedf46e83b5632cdeac91b8c04efc1"
],
"Parent": "",
"Comment": "",
"Created": "2020-12-08T00:22:53.076477777Z",
"Container": "395e0bfa7301f73bc994efe15099ea56b8836c608dd32614ac5ae279976d33e4",
"ContainerConfig": {
"Hostname": "395e0bfa7301",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"/bin/bash\"]"
],
"Image": "sha256:6de05bdfbf9a9d403458d10de9e088b6d93d971dd5d48d18b4b6758f4554f451",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"org.label-schema.build-date": "20201204",
"org.label-schema.license": "GPLv2",
"org.label-schema.name": "CentOS Base Image",
"org.label-schema.schema-version": "1.0",
"org.label-schema.vendor": "CentOS"
}
},
"DockerVersion": "19.03.12",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/bash"
],
"Image": "sha256:6de05bdfbf9a9d403458d10de9e088b6d93d971dd5d48d18b4b6758f4554f451",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"org.label-schema.build-date": "20201204",
"org.label-schema.license": "GPLv2",
"org.label-schema.name": "CentOS Base Image",
"org.label-schema.schema-version": "1.0",
"org.label-schema.vendor": "CentOS"
}
},
"Architecture": "amd64",
"Os": "linux",
"Size": 209348104,
"VirtualSize": 209348104,
"GraphDriver": {
"Data": {
"MergedDir": "/var/lib/docker/overlay2/e7f999e147eaa9cc6658059fe0a66e6f6bca79957c99cf69bfe563b82bcbd2be/merged",
"UpperDir": "/var/lib/docker/overlay2/e7f999e147eaa9cc6658059fe0a66e6f6bca79957c99cf69bfe563b82bcbd2be/diff",
"WorkDir": "/var/lib/docker/overlay2/e7f999e147eaa9cc6658059fe0a66e6f6bca79957c99cf69bfe563b82bcbd2be/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [ # 分层
"sha256:2653d992f4ef2bfd27f94db643815aa567240c37732cae1405ad1c1309ee9859"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]

进入正在运行的容器

  • 方法1:execute
1
2
3
4
docker exec -it 容器id /bin/bash  # 根据id重新进入容器交互,交互的command为/bin/bash

[root@VM-1-14-centos ~]# docker exec -it 813d27116121 /bin/bash
[root@813d27116121 /]#
  • 方法2:attach
1
2
3
4
5
docker attach 容器id  # 根据id重新进入容器交互,交互的command为之前设置的内容

[root@VM-1-14-centos ~]# docker attach 813d27116121
NephrenCake
......

在容器和宿主机之间拷贝文件

1
2
3
4
docker cp 容器id:容器内路径 目的主机的路径
docker cp 要拷贝的文件路径 容器名:要拷贝到容器里面对应的路径

[root@VM-1-14-centos ~]# docker cp 813d27116121:/home/test.java /home

这里拷贝是一个手动的过程,后面使用卷技术可以实现自动同步。

小结

1
2
3
docker commit -a "liuyifei" fd9913dfe5ba  sealocr:v1 
docker save -o my_ubuntu_v3.tar runoob/ubuntu:v3
docker export -o seal-ocr.tar fd9913dfe5ba

image-20210423164827183

部署Nginx、Tomcat、ES+Kibana

可视化

  • portainer
1
2
3
4
5
6
7
8
docker run -d -p 8080:9000 \
--restart=always -v /var/run/docker.sock:/var/run/docker.sock --privileged=true portainer/portainer

# 内网9000,外网8080
# --restart=always 启动方式
# -v 将数据挂载到本机
# --privileged=true 授权
# portainer/portainer 安装控制面板
  • Rancher

在 持续集成/持续部署(CI/CD) 时使用。