菜单

Juning
发布于 2020-05-24 / 979 阅读
2
0

Docker (二) Docker的常用命令

帮助命令

docker version		# 显示docker的版本信息
docker info				# 显示docker的系统信息,包括镜像和容器的数量
docker 命令 --help # 帮助命令

帮助文档的地址:https://docs.docker.com/engine/reference/

镜像命令

docker images 查看所有本地主机上的镜像

juning@chengjiajundeMacBook-Pro ~ % docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              latest              1b6b1fe7261e        7 days ago          647MB
# 注释
REPOSITORY  镜像的仓库
TAG					镜像的标签
IMAGE ID    镜像的ID
CREATED			镜像的创建时间
SIZE				镜像的大小

# 可选项
--all , -a		# 列出所有镜像
--no-trunc		# 只显示镜像的ID

docker search # 搜索命令

juning@chengjiajundeMacBook-Pro ~ % docker search mysql
NAME                              DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
mysql                             MySQL is a widely used, open-source relation…   9535                [OK]                
mariadb                           MariaDB is a community-developed fork of MyS…   3458                [OK]  

# 可选项,通过收藏来过滤
--filter=STARS=3000	#搜索出来的镜像STARS大于3000的
juning@chengjiajundeMacBook-Pro ~ % docker search mysql --filter=STARS=3000
NAME                DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
mysql               MySQL is a widely used, open-source relation…   9535                [OK]                
mariadb             MariaDB is a community-developed fork of MyS…   3458                [OK]                

docker pull # 下载镜像

# 下载镜像 docker pull 镜像名[:TAG]
juning@chengjiajundeMacBook-Pro ~ % docker pull nginx  
Using default tag: latest		# 如果不写tag,默认就是latest
latest: Pulling from library/nginx
afb6ec6fdc1c: Pull complete # 分层下载,docker image的核心 联合文件系统
b90c53a0b692: Pull complete 
11fa52a0fdc0: Pull complete 
Digest: sha256:30dfa439718a17baafefadf16c5e7c9d0a1cde97b4fd84f63b69e13513be7097 # 签名
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest #真实地址
# 说明
docker pull nginx等价docker.io/library/nginx:latest
# 指定版本下载
juning@chengjiajundeMacBook-Pro ~ % docker pull nginx:1.18
1.18: Pulling from library/nginx
afb6ec6fdc1c: Already exists 
2e231683bfde: Pull complete 
511e2efefada: Pull complete 
e8fd0ec105c9: Pull complete 
Digest: sha256:e4d21fc07f63bc115759f5826b04862053bd96b1a3bbfccb6b2a4cc92a2dc9cb
Status: Downloaded newer image for nginx:1.18
docker.io/library/nginx:1.18

docker rmi # 删除镜像

juning@chengjiajundeMacBook-Pro ~ % docker rmi 镜像ID  # 删除指定的镜像
juning@chengjiajundeMacBook-Pro ~ % docker rmi -f 镜像ID 镜像ID 镜像ID 镜像ID # 删除多个镜像
juning@chengjiajundeMacBook-Pro ~ % docker rmi -f $(docker images -aq) # 删除全部的镜像

容器命令

说明:有了镜像才可以创建容器,macOS下载一个centos镜像来进行学习

docker pull centos

新建容器并启动

docker run [可选参数] image

# 参数说明
--name="name"		指定容器名字  如:Tomcat1 Tomcat2 Tomcat3,用来区分容器
-d							后台方式运行
-it							使用交互方式运行,进入容器查看内容
-p							指定容器端口 -p 8080:8080
		-p ip:主机端口:容器端口
		-p 主机端口:容器端口(常用)
		-p 容器端口
		容器端口
-P							随机指定端口
# 测试,并进入容器
juning@chengjiajundeMacBook-Pro ~ % docker run -it centos /bin/bash
[root@31f3b7e068e5 /]# ls  # 查看容器内的centos,基础版本,很多命令都是不完整的
bin  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
# 从容器中退出主机
[root@31f3b7e068e5 /]# exit
exit
juning@chengjiajundeMacBook-Pro ~ % 

列出所有正在运行的容器

# docker ps 命令
				# 列出当前正在运行的容器
-a			# 列出当前正在运行的容器+带出历史运行过的容器
-n=?		# 显示最近创建的容器
-q			# 只显示容器的编号
juning@chengjiajundeMacBook-Pro ~ % docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
juning@chengjiajundeMacBook-Pro ~ % docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
31f3b7e068e5        centos              "/bin/bash"         3 minutes ago       Exited (0) 56 seconds ago                       ecstatic_tereshkova
juning@chengjiajundeMacBook-Pro ~ % 

退出容器

exit		# 直接容器退出,并退出
Ctrl + P + Q  # 容器不停止退出控制台

删除容器

docker rm [容器ID]							# 删除指定的容器,不能删除正在运行的容器,如果要删除,则需要-f
docker rm -f $(docker ps -aq)	 # 删除所有容器
docker ps -a -q|xargs docker rm # 删除所有容器

启动和停止容器的操作

docker start 容器ID				# 启动容器
docker restart 容器ID			# 重启容器
docker stop 容器ID				# 停止当前运行的容器
docker kill 容器ID				# 强制停止当前容器

常用的其它命令

后台启动

# 命令 docker run -d 镜像名
juning@chengjiajundeMacBook-Pro ~ % docker run -d centos
# 问题docker ps,发现centos停止了
# 常见的坑:docker容器使用后台运行,就必须要有一个前台进程,docker发现没有应用,就会自定停止
# 比如NGINX容器启动后,发现自己没有提供服务,容器就会立即停止

查看日志

docker logs -ft --tail 容器ID 发现没有日志
# 自己编写脚本,让后台输出点东西
juning@chengjiajundeMacBook-Pro ~ % docker run -d centos /bin/sh -c "while true;do echo juning;sleep 1;done"
247deddd895b1a41aee651c23a435068196e2cf50e1d3c33cd0bf6ab72928aed
# 显示日志
docker logs -ft 容器ID						# 显示所有日志
docker logs -ft --tail 10 容器ID  # 显示指定行数的日志
# 参数说明
-tf			# 显示日志
--tail	# 常用的tail命令,如控制显示的行数

查看容器中的进程信息 ps

# 命令 docker top 容器ID
juning@chengjiajundeMacBook-Pro ~ % docker top 24
PID                 USER                TIME                COMMAND
2759                root                0:00                /bin/sh -c while true;do echo juning;sleep 1;done
3278                root                0:00                {sleep} /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 1

查看镜像的元数据

# 命令
docker inspect 容器ID

# 测试
juning@chengjiajundeMacBook-Pro ~ % docker inspect 247deddd895b
[
    {
        "Id": "247deddd895b1a41aee651c23a435068196e2cf50e1d3c33cd0bf6ab72928aed",
        "Created": "2020-05-24T07:06:06.2886658Z",
        "Path": "/bin/sh",
        "Args": [
            "-c",
            "while true;do echo juning;sleep 1;done"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 2759,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2020-05-24T07:06:06.6112298Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:470671670cac686c7cf0081e0b37da2e9f4f768ddc5f6a26102ccd1c6954c1ee",
        "ResolvConfPath": "/var/lib/docker/containers/247deddd895b1a41aee651c23a435068196e2cf50e1d3c33cd0bf6ab72928aed/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/247deddd895b1a41aee651c23a435068196e2cf50e1d3c33cd0bf6ab72928aed/hostname",
        "HostsPath": "/var/lib/docker/containers/247deddd895b1a41aee651c23a435068196e2cf50e1d3c33cd0bf6ab72928aed/hosts",
        "LogPath": "/var/lib/docker/containers/247deddd895b1a41aee651c23a435068196e2cf50e1d3c33cd0bf6ab72928aed/247deddd895b1a41aee651c23a435068196e2cf50e1d3c33cd0bf6ab72928aed-json.log",
        "Name": "/cranky_kare",
        "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/4758e1c489bdfb2e86e1bce8f2094ccfca465f60ba34a5fae688681526769cf3-init/diff:/var/lib/docker/overlay2/94f859b0fe559436f2f092a942a44f27341a714e0a804ad393a80af4d4ee31db/diff",
                "MergedDir": "/var/lib/docker/overlay2/4758e1c489bdfb2e86e1bce8f2094ccfca465f60ba34a5fae688681526769cf3/merged",
                "UpperDir": "/var/lib/docker/overlay2/4758e1c489bdfb2e86e1bce8f2094ccfca465f60ba34a5fae688681526769cf3/diff",
                "WorkDir": "/var/lib/docker/overlay2/4758e1c489bdfb2e86e1bce8f2094ccfca465f60ba34a5fae688681526769cf3/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "247deddd895b",
            "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 juning;sleep 1;done"
            ],
            "Image": "centos",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "org.label-schema.build-date": "20200114",
                "org.label-schema.license": "GPLv2",
                "org.label-schema.name": "CentOS Base Image",
                "org.label-schema.schema-version": "1.0",
                "org.label-schema.vendor": "CentOS",
                "org.opencontainers.image.created": "2020-01-14 00:00:00-08:00",
                "org.opencontainers.image.licenses": "GPL-2.0-only",
                "org.opencontainers.image.title": "CentOS Base Image",
                "org.opencontainers.image.vendor": "CentOS"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "2cf61fdd59b62c3798f2452c1d3f7cb9a4fc9641eb955f77ba7f918addb58902",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/2cf61fdd59b6",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "7d59c3b05a9bf94c51fdf0d63bd32ab69428cc9677c61f2158be5d5a71177c04",
            "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": "50d5f42becda983f5de3b35e364eca15f4f1e34b0e74a94df8b54d8a7739ffbd",
                    "EndpointID": "7d59c3b05a9bf94c51fdf0d63bd32ab69428cc9677c61f2158be5d5a71177c04",
                    "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 /bashshell
# 测试
juning@chengjiajundeMacBook-Pro ~ % docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
247deddd895b        centos              "/bin/sh -c 'while t…"   16 minutes ago      Up 16 minutes                           cranky_kare
juning@chengjiajundeMacBook-Pro ~ % docker exec -it 247deddd895b /bin/bash
[root@247deddd895b /]# ls
bin  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[root@247deddd895b /]# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 07:06 ?        00:00:00 /bin/sh -c while true;do echo juning;sleep 1;done
root      1038     0  0 07:23 pts/0    00:00:00 /bin/bash
root      1156     1  0 07:25 ?        00:00:00 /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 1
root      1157  1038  0 07:25 pts/0    00:00:00 ps -ef

# 方式2
docker attach 容器ID 
# 测试
juning@chengjiajundeMacBook-Pro ~ % docker attach 247deddd895b  
正在执行当前的代码...

# docker exec			# 进入容器后开启一个新的终端,可以在里面操作(常用)
# docker attach		# 进入容器正在执行的终端,不会启动新的终端

从主机上拷贝文件到容器内

docker cp 容器ID:容器内路径  目的主机的路径

# 进入docker容器内部
juning@chengjiajundeMacBook-Pro ~ % docker attach aca654400b5c
[root@aca654400b5c /]# cd /home/
[root@aca654400b5c home]# ls
[root@aca654400b5c home]# pwd
/home
# 在容器内新建一个文件
[root@aca654400b5c home]# touch test.java
[root@aca654400b5c home]# ls
test.java
[root@aca654400b5c home]# exit
exit
juning@chengjiajundeMacBook-Pro ~ % docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
# 将文件拷贝到主机上
juning@chengjiajundeMacBook-Pro ~ % docker cp aca654400b5c:/home/test.java ~/ 
juning@chengjiajundeMacBook-Pro ~ % ls
Desktop			Downloads		Library			Music			Public			dev
Documents		IdeaProjects		Movies			Pictures		apache-maven-3.6.3	test.java
juning@chengjiajundeMacBook-Pro ~ % ls
Desktop			Downloads		Library			Music			Public			dev
Documents		IdeaProjects		Movies			Pictures		apache-maven-3.6.3	test.java
juning@chengjiajundeMacBook-Pro ~ % 

# 拷贝是一个手动过程,未来我们使用 -v 卷的技术,可以实现 容器内文件和主机文件自定同步

Docker命令

基本的docker命令,未根据模块分类,有些混乱,进入官方文档查看分类后的命令

命令描述
docker attach将本地标准输入,输出和错误流附加到正在运行的容器
docker build从Dockerfile构建镜像
docker builder管理构建
docker checkpoint管理检查点
docker commit根据容器更改创建新的镜像
docker config管理Docker配置
docker container管理容器
docker context管理上下文
docker cp在容器和本地文件系统之间拷贝文件或文件夹
docker create创建一个新的容器
docker deploy部署一个新的stack或升级一个已经存在的stack
docker diff检查容器的文件系统的文件或目录的更改
docker engine管理docker引擎
docker events从服务器获取实时事件
docker exec在正在运行的容器中运行命令行(不需要进入容器)
docker export将容器的文件系统导出为tar存档
docker history显示docker镜像的历史记录
docker image管理docker镜像
docker images列出docker镜像
docker import从tarball导入内容以创建文件系统映像
docker info显示系统范围的信息
docker inspect返回有关Docker对象的低等级信息
docker kill杀死一个或多个正在运行的容器(一般的,应使用docker stop终止容器)
docker load从tar存档或STDIN加载图像
docker login登录Docker registry注册服务器
docker logout从Docker registry注册服务器注销
docker logs获取容器的日志
docker manifest管理Docker镜像清单和清单列表
docker network管理网络
docker node管理Swarm节点
docker pause暂停一个或多个容器中的所有进程
docker plugin管理插件
docker port列出端口映射或容器的特定映射
docker ps列出容器
docker pull从注册服务器拉取镜像或镜像仓库
docker push将镜像或镜像仓库推送至注册服务器
docker rename重命名一个容器
docker restart重启一个或多个容器
docker rm删除一个或多个容器
docker rmi删除一个或多个镜像
docker run在一个新容器运行命令
docker save将一个或多个镜像保存到tar存档(默认情况下流式传输到STDOUT)
docker search在Docker Hub中搜索镜像
docker secret管理Docker的加密信息
docker service管理服务
docker stack管理docker stack
docker start启动一个或多个已停止的容器
docker stats显示容器资源使用情况统计信息的实时流
docker stop停止一个或多个正在运行的容器
docker swarm管理Swarm
docker system管理Docker
docker tag创建一个引用SOURCE_IMAGE的标记TARGET_IMAGE
docker top显示容器的运行进程
docker trust管理对Docker镜像的信任
docker unpause取消暂停一个或多个容器中的所有进程
docker update更新一个或多个容器的配置
docker version显示Docker版本信息
docker volume管理数量
docker wait阻止,直到一个或多个容器停止,然后打印退出代码

练习

Docker安装NGINX

# 1、拉取镜像 pull
# 2、运行
# 3、测试
juning@chengjiajundeMacBook-Pro ~ % docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
afb6ec6fdc1c: Pull complete 
b90c53a0b692: Pull complete 
11fa52a0fdc0: Pull complete 
Digest: sha256:30dfa439718a17baafefadf16c5e7c9d0a1cde97b4fd84f63b69e13513be7097
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
# -d 后台运行
# --name 给容器命名
# -p 主机端口:容器端口
juning@chengjiajundeMacBook-Pro ~ % docker run -d --name local_nginx -p8080:80 nginx
b727e5d75e31d734a77e58e385d0648a29da6267481fb749d6cc10fae406f595

juning@chengjiajundeMacBook-Pro ~ % docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
b727e5d75e31        nginx               "nginx -g 'daemon of…"   5 seconds ago       Up 5 seconds        0.0.0.0:8080->80/tcp   local_nginx
 
juning@chengjiajundeMacBook-Pro ~ % curl localhost:8080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

Docker部署es+kibana

es暴露的端口很多
es占用内存很多
es的数据一般需要放置到安全目录(挂载)

官网的启动方法如下:

$ docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:tag
# --net somenetwork ? 网络配置
# 启动elasticsearch
juning@chengjiajundeMacBook-Pro ~ % docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.7.0
9b1a965dfaa4d3e09d397251f81637adf4de5c0038877c49d6f507d0ea4e8959
# 启动完之后发现elasticsearch非常占用内存,我在自己的电脑上没觉得,但是执行docker stats查看一下状态
juning@chengjiajundeMacBook-Pro ~ % docker stats
CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
9b1a965dfaa4        elasticsearch       0.17%               1.237GiB / 1.944GiB   63.64%              2.42kB / 1.41kB     0B / 0B             54
# 可以看到elasticsearch占用了63%的EME,先看看elasticsearch是否启动成功
juning@chengjiajundeMacBook-Pro ~ % curl localhost:9200
{
  "name" : "9b1a965dfaa4",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "p3hlIhKRTFGLJrYqmrlbOg",
  "version" : {
    "number" : "7.7.0",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "81a1e9eda8e6183f5237786246f6dced26a10eaf",
    "build_date" : "2020-05-12T02:01:37.602180Z",
    "build_snapshot" : false,
    "lucene_version" : "8.5.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
# 修改配置文件 -e 环境配置修改
docker run -d --name elasticsearch02 -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx512m" elasticsearch:7.7.0
# 启动之后查看docker stats
CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
d697b51bb444        elasticsearch02     1.05%               467.8MiB / 1.944GiB   23.49%              906B / 0B           0B / 0B             55

评论