官网
https://docs.docker.com/
https://hub.docker.com/
基本命令 https://docs.docker.com/reference/commandline
1. 安装
uname -a # 查看版本信息
cat /etc/os-release # 查看版本信息
# 卸载旧版本
# 需要安装的包
yum install -y yun-utils
# 卸载
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
# 设置镜像的仓库
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # 镜像地址...
# 更新软件包索引
yum makecache fast
# 安装docker docker-ce社区 ee企业
yum install docker-ce docker-ce-cli containerd.io -y
# yum install docker-ce-<VERSION_STRING> docker-ce-<VERSION_STRING> containerd.io
# 启动docker
systemctl start docker
# 是否安装成功
docker version
2. 卸载
了解:卸载docker
# 卸载依赖
yum remove docker-ce docker-ce-cli containerd.io
# 删除资源
rm -rf /var/lib/docker
# /var/lib/docker docker的默认工作路径
# 阿里云加速配置
3. 镜像命令
# hello-world docker没找到helloworld然后下载后运行
docker run hello-world
# 查看 docker下的镜像
docker image
docker version #版本
docker info #详细信息
[root@instance-0mr70vm9 docker]# docker info
Client:
Debug Mode: false
Server:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 19.03.13
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-1127.8.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.952GiB
Name: instance-0mr70vm9
ID: TGZ4:KJKP:JRJE:2YM4:WSDG:DL2E:RARV:DMP4:WWI6:EAAP:X4CQ:WWJK
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://aa25jngun.mirror.aliyuncs.com/
Live Restore Enabled: false
docker --help #帮助命令
docker image --help # 查看docker镜像相关命令
# 搜索镜像 星超过3000
[root@instance-0mr70vm9 docker]# docker search mysql --filter=STARS=3000
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 10167 [OK]
mariadb MariaDB is a community-developed fork of MyS… 3742 [OK]
# 下载镜像 版本
docker pull 镜像[:tag]
docker pull mysql:5.7
[root@instance-0mr70vm9 docker]# docker pull mysql:5.7
5.7: Pulling from library/mysql
bb79b6b2107f: Already exists
49e22f6fb9f7: Already exists
842b1255668c: Already exists
9f48d1f43000: Already exists
c693f0615bce: Already exists
8a621b9dbed2: Already exists
0807d32aef13: Already exists
f15d42f48bd9: Pull complete
098ceecc0c8d: Pull complete
b6fead9737bc: Pull complete
351d223d3d76: Pull complete
Digest: sha256:4d2b34e99c14edb99cdd95ddad4d9aa7ea3f2c4405ff0c3509a29dc40bcb10ef
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
# 删除镜像
docker rmi -f 容器ID # 删除指定容器
docker rmi -f 容器ID 容器ID 容器ID 容器ID # 删除多个容器
[root@instance-0mr70vm9 docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.7 1b12f2e9257b 3 weeks ago 448MB
mysql latest db2b37ec6181 3 weeks ago 545MB
hello-world latest bf756fb1ae65 10 months ago 13.3kB
[root@instance-0mr70vm9 docker]# docker rmi -f 1b12f2e9257b
Untagged: mysql:5.7
Untagged: mysql@sha256:4d2b34e99c14edb99cdd95ddad4d9aa7ea3f2c4405ff0c3509a29dc40bcb10ef
Deleted: sha256:1b12f2e9257be96da5c075f186dc371b18442b0f9281728ac64c9a69c6e0e264
Deleted: sha256:b21d85dcc43f7db4e532c3ca07e5adbc1e02beb37646b7079217ea2b1922af91
Deleted: sha256:603c9faa831d58a3f60eb377cd6246a281a97b906406a92bf3452726a6f15b69
Deleted: sha256:2d927a6eb4cc26ba5454193a3f4abf503b6cea710293d4f0e6d061c08578b687
Deleted: sha256:b96c2c2176ca7b5223469ad39c9e17509505233dd81030878bc12b03074baef4
docker rmi -f $(docker images -aq) #删除全部容器
[root@instance-0mr70vm9 docker]# docker rmi -f $(docker images -aq)
Untagged: mysql:latest
Untagged: mysql@sha256:8c17271df53ee3b843d6e16d46cff13f22c9c04d6982eb15a9a47bd5c9ac7e2d
Deleted: sha256:db2b37ec6181ee1f367363432f841bf3819d4a9f61d26e42ac16e5bd7ff2ec18
Deleted: sha256:4d2a8e0ab441c5c1170a783be98b47096324f531f84cc387f06523af79ee7cd5
Deleted: sha256:09e5f20e5b3289cedaf4824906f74057b5b9b8765a246d8bfaafded2562a901a
Deleted: sha256:c25bdaaaf298842706f214fd3d855ca6f215cc66d01345efb9fd7479f6ca7b5f
Deleted: sha256:64231a7235fe05862b419beb8884dec599d27cab1b1bb402f0f75e64bc4cbd19
Deleted: sha256:79bc33a7ecad0032cc5e218d8b246b645f4cfddbf639b5db8383f81d4cbb6c9b
Deleted: sha256:33134afe9e842a2898e36966f222fcddcdb2ab42e65dcdc581a4b38b2852c2e0
Deleted: sha256:dd053ec71039c3646324372061452778609b9ba42d1501f6a72c0272c94f8965
Deleted: sha256:2d4c647f875f6256f210459e5c401aad27ad223d0fa3bada7c4088a6040f8ba4
Deleted: sha256:4bded7e9aa769cb0560e60da97421e2314fa896c719179b926318640324d7932
Deleted: sha256:5fd9447ef700dfe5975c4cba51d3c9f2e757b34782fe145c1d7a12dfbee1da2f
Deleted: sha256:5ee7cbb203f3a7e90fe67330905c28e394e595ea2f4aa23b5d3a06534a960553
Deleted: sha256:d0fe97fa8b8cefdffcef1d62b65aba51a6c87b6679628a2b50fc6a7a579f764c
Untagged: hello-world:latest
Untagged: hello-world@sha256:8c5aeeb6a5f3ba4883347d3747a7249f491766ca1caa47e5da5dfcf6b9b717c0
Deleted: sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b
容器命令
我们有了镜像才能创建容器,linux,下载一个centos镜像来学习
docker pull centos
新建容器并启动
docker run [可选参数] image
# 参数说明
--name=”容器名字“ tomcat01 tomcat02, 用来区分容器
-d 类似于nohup 后台方式运行
-it 使用交互方式运行,进入容器查看内容
-p 指定容器的端口 -p 8080:8080
-p 主机端口:容器端口(常用)
-p 容器端口
-P 随机指定端口
# 测试,运行并进入容器
[root@instance-0mr70vm9 docker]# docker run -it centos /bin/bash
# ”/bin/bash“ 或者 "/bin/sh" 指定控制台命令
[root@6c656ee65606 /]# ls
bin dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var
# 6c656ee65606 主机名是镜像id
# 从容器中退回主机
[root@6c656ee65606 /]# exit
exit
# 查看正在运行的容器
# docker ps 命令
-a # 列出当前正在运行 —— 带出历史运行过的容器
-n=1 # 显示最近创建的1个容器
-q #显示编号
[root@instance-0mr70vm9 docker]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6c656ee65606 centos "/bin/bash" 5 minutes ago Exited (0) 4 minutes ago frosty_bose
a80d629695e5 bf756fb1ae65 "/hello" About an hour ago Exited (0) About an hour ago competent_mendeleev
[root@instance-0mr70vm9 docker]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6c656ee65606 centos "/bin/bash" 5 minutes ago Exited (0) 4 minutes ago frosty_bose
a80d629695e5 bf756fb1ae65 "/hello" About an hour ago Exited (0) About an hour ago competent_mendeleev
[root@instance-0mr70vm9 docker]# docker ps -n=1
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6c656ee65606 centos "/bin/bash" 7 minutes ago Exited (0) 6 minutes ago frosty_bose
退出容器
exit # 直接容器停止退出
Ctrl + P + Q #容器不停止退出
删除容器
docker rm 容器ID #不能删除正在运行的容器
docker rm -f $(docker ps -qa) # 删除所有的容器
启动和停止容器的操作
docker start 容器ID # 启动容器
docker restart 容器ID # 重启容器
docker stop 容器ID # 停止当前正在运行的容器
docker kill 容器ID # 强制停止当前容器
# 查看容器内存
docker stats
容器和镜像的区别
刚才启动了已经删除了镜像的容器,证明容器是独立于镜像存在的。
容器应该是根据镜像构建出来的一个独立的环境,持久化在硬盘上的

image.png

容器和镜像的区别
常用其他命令
后台启动容器
# 命令docker run -d 镜像名
# docker容器使用后台运行,就必须要有一个前台进程,docker发现没有应用,docker发现没有应用就会自动停止。
# 编写一段shell脚本在容器中运行
[root@instance-0mr70vm9 docker]# docker run -d centos /bin/sh -c "while true;do echo shenbo; sleep 1;done"
51e4583f475ee92f54de936802e2444b19d5680d6f7868ec01be7fbc2e152635
[root@instance-0mr70vm9 docker]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
51e4583f475e centos "/bin/sh -c 'while t…" 9 seconds ago Up 8 seconds affectionate_benz
# 查看日志
-tf #显示日志
--tail number # 要显示日志条数
[root@instance-0mr70vm9 docker]# docker logs -tf --tail 100 51e4583f475e
2020-11-15T06:45:22.203064775Z shenbo
2020-11-15T06:45:23.205162997Z shenbo
2020-11-15T06:45:24.207315194Z shenbo
# 查看容器中进程信息
#命令 docker top 容器id
[root@instance-0mr70vm9 docker]# docker top 51e4583f475e
UID PID PPID C STIME TTY TIME
root 27016 27000 0 14:45 ? 00:0
root 27791 27016 0 14:56 ? 00:0
获取容器的详细信息
docker inspect 容器ID
[root@instance-0mr70vm9 docker]# docker inspect 51e4583f475e
[
{
# 真容器ID
"Id": "51e4583f475ee92f54de936802e2444b19d5680d6f7868ec01be7fbc2e152635",
"Created": "2020-11-15T06:45:21.878398747Z",
"Path": "/bin/sh",
# 启动容器带的参数
"Args": [
"-c",
"while true;do echo shenbo; sleep 1;done"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 27016,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-11-15T06:45:22.205006736Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:0d120b6ccaa8c5e149176798b3501d4dd1885f961922497cd0abef155c869566",
"ResolvConfPath": "/var/lib/docker/containers/51e4583f475ee92f54de936802e2444b19d5680d6f7868ec01be7fbc2e152635/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/51e4583f475ee92f54de936802e2444b19d5680d6f7868ec01be7fbc2e152635/hostname",
"HostsPath": "/var/lib/docker/containers/51e4583f475ee92f54de936802e2444b19d5680d6f7868ec01be7fbc2e152635/hosts",
"LogPath": "/var/lib/docker/containers/51e4583f475ee92f54de936802e2444b19d5680d6f7868ec01be7fbc2e152635/51e4583f475ee92f54de936802e2444b19d5680d6f7868ec01be7fbc2e152635-json.log",
"Name": "/affectionate_benz",
"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,
"Capabilities": null,
"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/e1e026ecea25e52c1f598458c4549bd3772356831a5eed4a3645e7331c40a17d-init/diff:/var/lib/docker/overlay2/be352701ffd2074ae2cbb6e2e35ab9c130f9dbfb2cc605f550797045dadaa7d3/diff",
"MergedDir": "/var/lib/docker/overlay2/e1e026ecea25e52c1f598458c4549bd3772356831a5eed4a3645e7331c40a17d/merged",
"UpperDir": "/var/lib/docker/overlay2/e1e026ecea25e52c1f598458c4549bd3772356831a5eed4a3645e7331c40a17d/diff",
"WorkDir": "/var/lib/docker/overlay2/e1e026ecea25e52c1f598458c4549bd3772356831a5eed4a3645e7331c40a17d/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "51e4583f475e",
"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 shenbo; sleep 1;done"
],
"Image": "centos",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"org.label-schema.build-date": "20200809",
"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": "137979b06b19c46098cb8b4b0bcd18853ef7222c28f0617e15954a1fbc2b9699",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/137979b06b19",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "efd5f0592d35b459c187188a17b2f23638bb16e6d03ad99713157a0ee44ec615",
"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": "03484c3be20c186e11b7962984aef98da59b9f245327dca1f9601966cd9a0723",
"EndpointID": "efd5f0592d35b459c187188a17b2f23638bb16e6d03ad99713157a0ee44ec615",
"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
}
}
}
}
]
进入当前正在运行的容器
docker exec -it 容器ID /bin/bash # 进入后开启一个新的终端,可以在里边操作(常用)
docker attach 容器ID # 进入正在执行的终端,不会启动新的进程
从容器内拷贝文件到宿主机上
[root@instance-0mr70vm9 ~]# docker cp b9844e17f80b:/root/shenbo-rq.java shenbo-rq.java
[root@instance-0mr70vm9 ~]# ls
shenbo-rq.java shenbo-szj.java
# 拷贝是一个手动过程,未来我们使用 -v卷的技术,可以实现

image.png

timg.jpg

u=4158452438,1818582037&fm=26&gp=0.jpg
启动一个nginx容器
[root@instance-0mr70vm9 ~]# docker run -d --name nginx01 -p 3344:80 nginx
b2f350aac6c118355317164d0490b595f4e82c6fed65895ae8e1472a02cc6d83
[root@instance-0mr70vm9 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b2f350aac6c1 nginx "/docker-entrypoint.…" 10 seconds ago Up 9 seconds 0.0.0.0:3344->80/tcp nginx01
b9844e17f80b centos "/bin/bash" 13 minutes ago Up 13 minutes intelligent_joliot
[root@instance-0mr70vm9 ~]# docker stop b9844e17f80b
b9844e17f80b
[root@instance-0mr70vm9 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b2f350aac6c1 nginx "/docker-entrypoint.…" 28 seconds ago Up 27 seconds 0.0.0.0:3344->80/tcp nginx01
[root@instance-0mr70vm9 ~]# curl locahost:3344
curl: (6) Could not resolve host: locahost; Name or service not known
[root@instance-0mr70vm9 ~]# curl 127.0.0.1:3344
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
启动一个tomcat容器
[root@instance-0mr70vm9 ~]# docker pull tomcat:9.0
9.0: Pulling from library/tomcat
e4c3d3e4f7b0: Pull complete
101c41d0463b: Pull complete
8275efcd805f: Pull complete
751620502a7a: Pull complete
a59da3a7d0e7: Pull complete
9c0f1dffe039: Pull complete
576e3c6f47f8: Pull complete
c7e1b6c3ef84: Pull complete
d1b8a428acdc: Pull complete
7251ae448a6d: Pull complete
Digest: sha256:5b17d5de9c75c9da638c28186c19423b610e7eab3b6f6b975bf47383d12ed0a9
Status: Downloaded newer image for tomcat:9.0
docker.io/library/tomcat:9.0
[root@instance-0mr70vm9 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat 9.0 2703bbe9e9d4 3 days ago 648MB
nginx latest c39a868aad02 9 days ago 133MB
centos latest 0d120b6ccaa8 3 months ago 215MB
[root@instance-0mr70vm9 ~]# docker run -d -p 3355:8080 --name tomcat01 tomcat
Unable to find image 'tomcat:latest' locally
latest: Pulling from library/tomcat
Digest: sha256:5b17d5de9c75c9da638c28186c19423b610e7eab3b6f6b975bf47383d12ed0a9
Status: Downloaded newer image for tomcat:latest
51074349b5eeb90bef9ef58c781c1e9b500075de1572198e648aeb1165aa22d4
[root@instance-0mr70vm9 ~]# curl localhost:3345
curl: (7) Failed connect to localhost:3345; Connection refused
[root@instance-0mr70vm9 ~]# curl localhost:3355
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/9.0.39</h3></body></html>
[root@instance-0mr70vm9 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b2f350aac6c1 nginx "/docker-entrypoint.…" 31 minutes ago Up 31 minutes 0.0.0.0:3344->80/tcp nginx01
[root@instance-0mr70vm9 ~]# docker start tomcat01
tomcat01
[root@instance-0mr70vm9 ~]# docker exec -it tomcat01 /bin/bash
docker启动一个es + kibana环境
[root@instance-0mr70vm9 ~]# docker pull elasticsearch:7.6.2
7.6.2: Pulling from library/elasticsearch
ab5ef0e58194: Pull complete
c4d1ca5c8a25: Pull complete
941a3cc8e7b8: Pull complete
43ec483d9618: Pull complete
c486fd200684: Pull complete
1b960df074b2: Pull complete
1719d48d6823: Pull complete
Digest: sha256:1b09dbd93085a1e7bca34830e77d2981521a7210e11f11eda997add1c12711fa
Status: Downloaded newer image for elasticsearch:7.6.2
docker.io/library/elasticsearch:7.6.2
[root@instance-0mr70vm9 ~]# docker run -d --name es7.6 -p 9200:9200 -p9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx512m" elasticsearch:7.6.2
e86fe28f56e22600a8f22450b9a75bcc71fda0eeb497450ad73802a6bf2185f1
[root@instance-0mr70vm9 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e86fe28f56e2 elasticsearch:7.6.2 "/usr/local/bin/dock…" 8 seconds ago Up 6 seconds 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp es7.6
[root@instance-0mr70vm9 ~]# docker stats
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
e86fe28f56e2 es7.6 0.13% 348.3MiB / 1.952GiB 17.43% 9.96kB / 6.73kB 0B / 696kB 44
可视化
- portainer (Docker图形化管理工具! 提供一个后台面板供我们操作!)
[root@instance-0mr70vm9 ~]# docker run -d -p 8088:9000 --restart=always -v "/var/run/docker.sock:/var/run/docker.sock" --privileged=true portainer/portainer
Unable to find image 'portainer/portainer:latest' locally
latest: Pulling from portainer/portainer
d1e017099d17: Pull complete
717377b83d5c: Pull complete
Digest: sha256:f8c2b0a9ca640edf508a8a0830cf1963a1e0d2fd9936a64104b3f658e120b868
Status: Downloaded newer image for portainer/portainer:latest
9456a8202750835afa674ae2bed16ce5fb80924effdc8872e5ece579890aca99
然后登陆
http://106.13.186.24:8088/#/init/endpoint
设置用户名密码之后进入一下页面

image.png