0%

Docker 入门学习笔记

命令速查

Docker 学习笔记,理解并解释所有命令

命令速查

安装Docker

环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@Test_10 ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

联网安装

官方文档
centos

卸载旧版本

script
1
2
3
4
5
6
7
8
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine

需要的安装包(依赖?)

script
1
sudo yum install -y yum-utils

设置镜像仓库

script
1
2
3
4
5
6
7
8
#官方镜像
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
#阿里云镜像
sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

更新软件包索引

script
1
yum makecache fast

安装dokcer

最新版

script
1
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

指定版
列出版本

script
1
2
3
4
5
6
yum list docker-ce --showduplicates | sort -r

docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable

安装指定版本

script
1
sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io docker-buildx-plugin docker-compose-plugin


启动

script
1
2
3
sudo systemctl start docker
docker version
systemctl restart docker.service

Hello wrld

script
1
sudo docker run hello-world

查看一下helloword 镜像

script
1
docker images

离线安装

卸载

卸载软件包

script
1
sudo yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras

删除所有资源

script
1
2
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
  1. run 的流程

底层原理

docker是一个client—server结构的系统
docker的守护进程运行在主机上
通过Socket从客户端访问
DockerServer接收到Docker-Client的指令就会执行这个命令!

Docker为什么比VM快
1.docker有比虚拟机更少的抽象层
2.docler用的是宿主机的内核,vm需要的是Guest OS

所以说docker不需要重新加载操作系统内核,避免引导。

基本命令

基本信息

docker 的版本

script
1
docker version 

docker的基本信息

script
1
docker info

帮助命令

script
1
docker [命令] --help  

镜像命令

展示镜像

用法

https://docs.docker.com/engine/reference/commandline/images/

script
1
docker images --help  

可选项

1
2
3
4
-a, --all             列出所有镜像
-f, --filter filter 过滤
-q, --quiet 只显示镜像id

使用

script
1
docker images

解释
REPOSITORY 镜像的仓库源
TAG 镜像的标签
IMAGE ID 镜像的id
CREATED 镜像的创建时间
SIZE 镜像的大小
script
1
docker images -a
script
1
docker images -q

搜索镜像

用法

https://docs.docker.com/engine/reference/commandline/search/

script
1
docker search --help  

可选项

script
1
2
3
4
-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
--no-trunc Don't truncate output

使用

script
1
docker search mysql

script
1
docker search mysql --filter=STARS=3000

下载镜像

用法

https://docs.docker.com/engine/reference/commandline/pull/

script
1
docker pull --help  

可选项

script
1
2
3
4
-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

使用

script
1
2
docker pull mysql
docker pull docker.io/library/mysql:latest

script
1
2
3
docker pull mysql:5.7
docker pull mysql:5.7.30
docker pull mysql:5.7.41

删除镜像

用法

https://docs.docker.com/engine/reference/commandline/rmi/

script
1
docker rmi --help  

可选项

script
1
2
-f, --force      Force removal of the image
--no-prune Do not delete untagged parents

使用

删除一个

script
1
2
docker images
docker rmi -f 9cfcce23593a

删除全部

script
1
docker rmi -f $(docker images -aq)

容器命令

新建并运行容器

用法

https://docs.docker.com/engine/reference/commandline/run/

script
1
docker rmi --help  
script
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
      --add-host list                  Add a custom host-to-IP mapping (host:ip)
-a, --attach list Attach to STDIN, STDOUT or STDERR
--blkio-weight uint16 Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
--blkio-weight-device list Block IO weight (relative device weight) (default [])
--cap-add list Add Linux capabilities
--cap-drop list Drop Linux capabilities
--cgroup-parent string Optional parent cgroup for the container
--cgroupns string Cgroup namespace to use (host|private)
'host': Run the container in the Docker host's cgroup namespace
'private': Run the container in its own private cgroup namespace
'': Use the cgroup namespace as configured by the
default-cgroupns-mode option on the daemon (default)
--cidfile string Write the container ID to the file
--cpu-period int Limit CPU CFS (Completely Fair Scheduler) period
--cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota
--cpu-rt-period int Limit CPU real-time period in microseconds
--cpu-rt-runtime int Limit CPU real-time runtime in microseconds
-c, --cpu-shares int CPU shares (relative weight)
--cpus decimal Number of CPUs
--cpuset-cpus string CPUs in which to allow execution (0-3, 0,1)
--cpuset-mems string MEMs in which to allow execution (0-3, 0,1)
-d, --detach Run container in background and print container ID
--detach-keys string Override the key sequence for detaching a container
--device list Add a host device to the container
--device-cgroup-rule list Add a rule to the cgroup allowed devices list
--device-read-bps list Limit read rate (bytes per second) from a device (default [])
--device-read-iops list Limit read rate (IO per second) from a device (default [])
--device-write-bps list Limit write rate (bytes per second) to a device (default [])
--device-write-iops list Limit write rate (IO per second) to a device (default [])
--disable-content-trust Skip image verification (default true)
--dns list Set custom DNS servers
--dns-option list Set DNS options
--dns-search list Set custom DNS search domains
--domainname string Container NIS domain name
--entrypoint string Overwrite the default ENTRYPOINT of the image
-e, --env list Set environment variables
--env-file list Read in a file of environment variables
--expose list Expose a port or a range of ports
--gpus gpu-request GPU devices to add to the container ('all' to pass all GPUs)
--group-add list Add additional groups to join
--health-cmd string Command to run to check health
--health-interval duration Time between running the check (ms|s|m|h) (default 0s)
--health-retries int Consecutive failures needed to report unhealthy
--health-start-period duration Start period for the container to initialize before starting health-retries countdown
(ms|s|m|h) (default 0s)
--health-timeout duration Maximum time to allow one check to run (ms|s|m|h) (default 0s)
--help Print usage
-h, --hostname string Container host name
--init Run an init inside the container that forwards signals and reaps processes
-i, --interactive Keep STDIN open even if not attached
--ip string IPv4 address (e.g., 172.30.100.104)
--ip6 string IPv6 address (e.g., 2001:db8::33)
--ipc string IPC mode to use
--isolation string Container isolation technology
--kernel-memory bytes Kernel memory limit
-l, --label list Set meta data on a container
--label-file list Read in a line delimited file of labels
--link list Add link to another container
--link-local-ip list Container IPv4/IPv6 link-local addresses
--log-driver string Logging driver for the container
--log-opt list Log driver options
--mac-address string Container MAC address (e.g., 92:d0:c6:0a:29:33)
-m, --memory bytes Memory limit
--memory-reservation bytes Memory soft limit
--memory-swap bytes Swap limit equal to memory plus swap: '-1' to enable unlimited swap
--memory-swappiness int Tune container memory swappiness (0 to 100) (default -1)
--mount mount Attach a filesystem mount to the container
--name string Assign a name to the container
--network network Connect a container to a network
--network-alias list Add network-scoped alias for the container
--no-healthcheck Disable any container-specified HEALTHCHECK
--oom-kill-disable Disable OOM Killer
--oom-score-adj int Tune host's OOM preferences (-1000 to 1000)
--pid string PID namespace to use
--pids-limit int Tune container pids limit (set -1 for unlimited)
--platform string Set platform if server is multi-platform capable
--privileged Give extended privileges to this container
-p, --publish list Publish a container's port(s) to the host
-P, --publish-all Publish all exposed ports to random ports
--pull string Pull image before running ("always", "missing", "never") (default "missing")
-q, --quiet Suppress the pull output
--read-only Mount the container's root filesystem as read only
--restart string Restart policy to apply when a container exits (default "no")
--rm Automatically remove the container when it exits
--runtime string Runtime to use for this container
--security-opt list Security Options
--shm-size bytes Size of /dev/shm
--sig-proxy Proxy received signals to the process (default true)
--stop-signal string Signal to stop the container
--stop-timeout int Timeout (in seconds) to stop a container
--storage-opt list Storage driver options for the container
--sysctl map Sysctl options (default map[])
--tmpfs list Mount a tmpfs directory
-t, --tty Allocate a pseudo-TTY
--ulimit ulimit Ulimit options (default [])
-u, --user string Username or UID (format: <name|uid>[:<group|gid>])
--userns string User namespace to use
--uts string UTS namespace to use
-v, --volume list Bind mount a volume
--volume-driver string Optional volume driver for the container
--volumes-from list Mount volumes from the specified container(s)
-w, --workdir string Working directory inside the container

--name="Username" #容器名称
-d #后台方式运行
-it #交互运行
-p #指定端口
-p ip:主机端口:容器端口
-p 主机端口:容器端口
-p 容器端口
-P #随机指定端口

使用

有镜像才可以创建容器,下载一个centos用来学习

script
1
docker pull centos

新建并启动

script
1
docker run -it centos /bin/bash

退出容器

script
1
2
exit #退出并停止
Ctrl + P + Q #容器不停止退出

列出容器

用法

https://docs.docker.com/engine/reference/commandline/ps/

script
1
docker ps -help

可选项

script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
-a, --all             Show all containers (default shows just running)
-f, --filter filter Filter output based on conditions provided
--format string Format output using a custom template:
'table': Print output in table format with column headers (default)
'table TEMPLATE': Print output in table format using the given Go template
'json': Print in JSON format
'TEMPLATE': Print output using the given Go template.
Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with
templates
-n, --last int Show n last created containers (includes all states) (default -1)
-l, --latest Show the latest created container (includes all states)
--no-trunc Don't truncate output
-q, --quiet Only display container IDs
-s, --size Display total file sizes

使用

script
1
docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a8a6a8281212 centos “/bin/bash” 8 minutes ago Exited (127) 2 minutes ago sweet_fermi
0c7e1f91d4e5 centos “/bin/bash” 9 minutes ago Exited (127) 9 minutes ago silly_rosalind
2fdc61324e58 centos “/bin/bash” 9 minutes ago Exited (0) 9 minutes ago epic_vaughan
ab985dc1aa20 hello-world “/hello” 4 hours ago Exited (0) 4 hours ago keen_austin

script
1
docker ps -a

script
1
docker ps -a -n=2

script
1
docker ps -aq

启动容器

https://docs.docker.com/engine/reference/commandline/start/

script
1
docker start --help

重启容器

https://docs.docker.com/engine/reference/commandline/restart/

script
1
docker restart --help

停止容器

https://docs.docker.com/engine/reference/commandline/stop/

script
1
docker stop --help

强制停止容器

https://docs.docker.com/engine/reference/commandline/kill/

script
1
docker kill --help

删除容器

https://docs.docker.com/engine/reference/commandline/rm/

用法

script
1
docker rm --help

可选项

1
2
3
-f, --force     Force the removal of a running container (uses SIGKILL)
-l, --link Remove the specified link
-v, --volumes Remove anonymous volumes associated with the container

使用

script
1
2
3
docker ps -a
docker rm ab985dc1aa20
docker ps -a

script
1
2
3
4
docker ps -a
docker rm -f $(docker ps -aq)
# docker ps -aq | xargs docker rm -f
docker ps -a

其他命令

后台启动

script
1
2
3
docker rm -f $(docker ps -aq)
docker run -d centos
docker ps -a

查看日志

https://docs.docker.com/engine/reference/commandline/logs/

script
1
docker logs --help
script
1
2
3
4
5
docker rm -f $(docker ps -aq)
docker run -d centos /bin/sh -c "while true; do echo "tes1"; sleep 1; done"
docker ps
docker logs -f -t $(docker ps -q)
docker logs -f -t --tail -100f $(docker ps -q)

script
1
2
3
4
5
6
7
```

### <span id="top"/>容器进程
https://docs.docker.com/engine/reference/commandline/top/
```shell script
docker ps
docker top a72c9bde51d7

容器元数据

https://docs.docker.com/engine/reference/commandline/inspect/

script
1
docker inspect --help
script
1
2
docker ps
docker inspect a72c9bde51d7

结果

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
[
{
"Id": "a72c9bde51d75bbd5d734edd5421ab0da5ca21db6dbc96c319c0e500a66eec71",
"Created": "2023-04-08T10:52:05.424709448Z",
"Path": "/bin/sh",
"Args": [
"-c",
"while true; do echo tes1; sleep 1; done"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 17369,
"ExitCode": 0,
"Error": "",
"StartedAt": "2023-04-08T10:52:05.655301603Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:5d0da3dc976460b72c77d94c8a1ad043720b0416bfc16c52c45d4847e53fadb6",
"ResolvConfPath": "/var/lib/docker/containers/a72c9bde51d75bbd5d734edd5421ab0da5ca21db6dbc96c319c0e500a66eec71/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/a72c9bde51d75bbd5d734edd5421ab0da5ca21db6dbc96c319c0e500a66eec71/hostname",
"HostsPath": "/var/lib/docker/containers/a72c9bde51d75bbd5d734edd5421ab0da5ca21db6dbc96c319c0e500a66eec71/hosts",
"LogPath": "/var/lib/docker/containers/a72c9bde51d75bbd5d734edd5421ab0da5ca21db6dbc96c319c0e500a66eec71/a72c9bde51d75bbd5d734edd5421ab0da5ca21db6dbc96c31 9c0e500a66eec71-json.log",
"Name": "/upbeat_wilbur",
"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,
"ConsoleSize": [
51,
161
],
"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",
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": [],
"BlkioDeviceWriteBps": [],
"BlkioDeviceReadIOps": [],
"BlkioDeviceWriteIOps": [],
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"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/4d2bcefab4858ec9e3ef29ceda025e536580f799438c812c75edb96119181199-init/diff:/var/lib/docker/overlay2/7d8038e 1f6f5d7263daac0fc714b58a3ffac805e4e9f1db889637f2bb7a89db2/diff",
"MergedDir": "/var/lib/docker/overlay2/4d2bcefab4858ec9e3ef29ceda025e536580f799438c812c75edb96119181199/merged",
"UpperDir": "/var/lib/docker/overlay2/4d2bcefab4858ec9e3ef29ceda025e536580f799438c812c75edb96119181199/diff",
"WorkDir": "/var/lib/docker/overlay2/4d2bcefab4858ec9e3ef29ceda025e536580f799438c812c75edb96119181199/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "a72c9bde51d7",
"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",
"while true; do echo tes1; sleep 1; done"
],
"Image": "centos",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"org.label-schema.build-date": "20210915",
"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": "3d571989560c19ddf4575a08d63a513aaca3e42858daa3de3833aede2243da07",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/3d571989560c",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "1a4acce827664746cb743281b045025ef90c637e9f40ef851d0ff26f9f8ce269",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "f53f3c88c2cda13da05b51d9ceaf852850259a229c9da7fbcc952edfc1125168",
"EndpointID": "1a4acce827664746cb743281b045025ef90c637e9f40ef851d0ff26f9f8ce269",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
]

进入容器

https://docs.docker.com/engine/reference/commandline/inspect/

script
1
docker exec --help
script
1
docker exec -it [容器id] [command] 
script
1
2
docker ps
docker exec -it a72c9bde51d7 /bin/bash

https://docs.docker.com/engine/reference/commandline/attach/

script
1
docker attach [容器id]
script
1
2
docker ps
docker attach a72c9bde51d7

attach 不会开启新进程

容器内文件拷出

https://docs.docker.com/engine/reference/commandline/cp/

script
1
2
docker cp --help
docker cp [容器id]:[容器内路径] [目的地主机路径]
script
1
2
3
4
5
6
7
docker ps
docker exec -it a72c9bde51d7 /bin/bash
touch testaaa.txt
ls -al
exit
docker cp a72c9bde51d7:/testaaa.txt ./testaaa.txt
ls -al

实战

实战 nginx

script
1
2
docker pull nginx
docker images

script
1
2
docker run -d --name nginx01 -p:9999:80 nginx
docker ps

script
1
curl 127.0.0.1:9999

script
1
docker exec -it -nginx01 /bin/bash

实战 tomcat

script
1
docker pull tomcat:9.0

script
1
docker images

script
1
2
docker run -d -p 1234:8080 --name tomcat01 tomcat:9.0
curl 127.0.0.1:1234

script
1
docker ps

script
1
docker exec -it tomcat01 /bin/bash

实战 elasticsearch

script
1
2
docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.2
docker ps

Snipaste_2023-04-08_21-16-09.png

实战 kibana

实战 portainer

docker run -d -p 8088:9000 –restart=always -v /var/run/docker.sock:/var/run/docker.sock –privileged=true portainer/portainer
docker run -d -p 8088:9000 –restart=always -v /var/run/docker.sock:/var/run/docker.sock –privileged=true 6053537/portainer-ce

docker run -d –restart=always –name=”portainer” -p 8088:9000 -v /var/run/docker.sock:/var/run/docker.sock -v

镜像讲解

镜像是什么

加载原理

分层理解

命令解析

命令速查

—- —-
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
builder Manage builds
checkpoint Manage checkpoints
commit Create a new image from a container’s changes
config Manage Swarm configs
container Manage containers
context Manage contexts
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container’s filesystem
events Get real time events from the server
exec Execute a command in a running container
export Export a container’s filesystem as a tar archive
history Show the history of an image
image Manage images
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a registry
logout Log out from a registry
logs Fetch the logs of a container
manifest Manage Docker image manifests and manifest lists
network Manage networks
node Manage Swarm nodes
pause Pause all processes within one or more containers
plugin Manage plugins
port List port mappings or a specific mapping for the container
ps List containers
pull Download an image from a registry
push Upload an image to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Create and run a new container from an image
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search Docker Hub for images
secret Manage Swarm secrets
service Manage Swarm services
stack Manage Swarm stacks
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
swarm Manage Swarm
system Manage Docker
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
trust Manage trust on Docker images
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
volume Manage volumes
wait Block until one or more containers stop, then print their exit codes