Docker 运行 安装卷但 docker 检查卷为空
Docker run mounting volumes but docker inspect has volumes as null
我的问题是关于我创建的 docker 运行 命令,它是 运行 完成和创建服务,但是它有 mount/volume 问题。我正在 运行 执行以下命令:
docker run -d --restart=unless-stopped --log-driver json-file --log-opt max-file="3" --log-opt max-size="15m" -m 2.875g --cpu-shares=230 --ulimit nofile=262144:262144 --ulimit memlock=-1:-1 --group-add="elasticsearch" --user="elasticsearch" --net="host" -p 192.168.56.103:9200:9200 -p 192.168.56.103:9300:9300 -v /var/qpackage/elasticsearch/repo:/usr/share/elasticsearch/repo:rw -v /etc/qpackage/elasticsearch/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:rw -v /var/qpackage/elasticsearch/data:/usr/share/elasticsearch/data:rw -v /etc/qpackage/elasticsearch/conf/jvm.options:/usr/share/elasticsearch/config/jvm.options:rw -e "SERVICE_9200_NAME=elasticsearch" -e "SERVICE_9300_NAME=elasticsearch-node" --name elasticsearch-1_log_elasticsearch cp-elasticsearch:7.1.ox
它似乎 运行 非常好。但是,当我执行 docker inspect
时,我注意到当我放置在命令中的卷正在安装并且绑定正确时,检查还显示卷为空。这是不正确的行为。卷应该显示。
当前结果
"Volumes": null,
预期结果
"Volumes": {
"/usr/share/elasticsearch/config/elasticsearch.yml": {},
"/usr/share/elasticsearch/config/jvm.options": {},
"/usr/share/elasticsearch/data": {},
"/usr/share/elasticsearch/repo": {}
},
我可能做错了什么?
完全Docker检查
[root@localhost tmp]# docker inspect elasticsearch-1_log_elasticsearch
[
{
"Id": "be782ca624a468e30dd8c79748ef5406781134c3b6f93450b3b3f425af701301",
"Created": "2019-11-18T21:48:34.243146943Z",
"Path": "/usr/local/bin/docker-entrypoint.sh",
"Args": [
"eswrapper"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 18111,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-11-18T21:48:34.645908733Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:6e4f392617213267be91ed63bcd83a425425ed825cf0ab1f346d55375e48d91b",
"ResolvConfPath": "/var/qpackage/docker/containers/be782ca624a468e30dd8c79748ef5406781134c3b6f93450b3b3f425af701301/resolv.conf",
"HostnamePath": "/var/qpackage/docker/containers/be782ca624a468e30dd8c79748ef5406781134c3b6f93450b3b3f425af701301/hostname",
"HostsPath": "/var/qpackage/docker/containers/be782ca624a468e30dd8c79748ef5406781134c3b6f93450b3b3f425af701301/hosts",
"LogPath": "/var/qpackage/docker/containers/be782ca624a468e30dd8c79748ef5406781134c3b6f93450b3b3f425af701301/be782ca624a468e30dd8c79748ef5406781134c3b6f93450b3b3f425af701301-json.log",
"Name": "/elasticsearch-1_log_elasticsearch",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/etc/qpackage/elasticsearch/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml",
"/var/qpackage/elasticsearch/data:/usr/share/elasticsearch/data",
"/etc/qpackage/elasticsearch/conf/jvm.options:/usr/share/elasticsearch/config/jvm.options",
"/var/qpackage/elasticsearch/repo:/usr/share/elasticsearch/repo"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {
"max-file": "3",
"max-size": "15m"
}
},
"NetworkMode": "host",
"PortBindings": {
"9200/tcp": [
{
"HostIp": "192.168.56.103",
"HostPort": "9200"
}
],
"9300/tcp": [
{
"HostIp": "192.168.56.103",
"HostPort": "9300"
}
]
},
"RestartPolicy": {
"Name": "unless-stopped",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": [
"elasticsearch"
],
"IpcMode": "shareable",
"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": 230,
"Memory": 3087007744,
"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,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 6174015488,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": [
{
"Name": "nofile",
"Hard": 262144,
"Soft": 262144
},
{
"Name": "memlock",
"Hard": -1,
"Soft": -1
}
],
"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/qpackage/docker/overlay2/f23fc0453e6ef6309612864951ffa3d279dd1197a9f2cb5e27fb7884c16eba69-init/diff:/var/qpackage/docker/overlay2/cc295c456ff0d7a6e33e62578915d4b2dfaec5778e3c7c95a15862333f2ddc87/diff:/var/qpackage/docker/overlay2/baa3e9c814aa237120bbd1668a8dfec75444e3d44ec46afdaf818b03d0584bb6/diff:/var/qpackage/docker/overlay2/ac48075afe8ae211844285573419bc9e08b92b89877deca5b10eed7f071fd43c/diff:/var/qpackage/docker/overlay2/b1395bb3de16587b201eceaa1468951c1224fcd37d3e49ff012954fa0e621836/diff:/var/qpackage/docker/overlay2/a2ac251b148df5aba19addea36ecd85b7b45a5590740684ae928586f55a93fdc/diff:/var/qpackage/docker/overlay2/0cb5d6a8739367e5eab2b071f5ec3f4cb6e4d62b4d94a4919635ec05e7a6198f/diff:/var/qpackage/docker/overlay2/67657868ee478d3cb47093c67d1824eb873e2628840486bb63aef7eee29652bd/diff:/var/qpackage/docker/overlay2/108ed1526882b849cf3991c8177b7389e84da4b9a48828f43b08351b6c69ddf0/diff",
"MergedDir": "/var/qpackage/docker/overlay2/f23fc0453e6ef6309612864951ffa3d279dd1197a9f2cb5e27fb7884c16eba69/merged",
"UpperDir": "/var/qpackage/docker/overlay2/f23fc0453e6ef6309612864951ffa3d279dd1197a9f2cb5e27fb7884c16eba69/diff",
"WorkDir": "/var/qpackage/docker/overlay2/f23fc0453e6ef6309612864951ffa3d279dd1197a9f2cb5e27fb7884c16eba69/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/etc/qpackage/elasticsearch/conf/elasticsearch.yml",
"Destination": "/usr/share/elasticsearch/config/elasticsearch.yml",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/var/qpackage/elasticsearch/data",
"Destination": "/usr/share/elasticsearch/data",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/etc/qpackage/elasticsearch/conf/jvm.options",
"Destination": "/usr/share/elasticsearch/config/jvm.options",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/var/qpackage/elasticsearch/repo",
"Destination": "/usr/share/elasticsearch/repo",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "localhost.localdomain",
"Domainname": "",
"User": "elasticsearch",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"9200/tcp": {},
"9300/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"SERVICE_9200_NAME=elasticsearch",
"SERVICE_9300_NAME=elasticsearch-node",
"PATH=/usr/share/elasticsearch/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"ELASTIC_CONTAINER=true"
],
"Cmd": [
"eswrapper"
],
"ArgsEscaped": true,
"Image": "cp-elasticsearch:7.1.ox",
"Volumes": null,
"WorkingDir": "/usr/share/elasticsearch",
"Entrypoint": [
"/usr/local/bin/docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {
"license": "Elastic License",
"org.label-schema.build-date": "20190305",
"org.label-schema.license": "GPLv2",
"org.label-schema.name": "elasticsearch",
"org.label-schema.schema-version": "1.0",
"org.label-schema.url": "https://www.elastic.co/products/elasticsearch",
"org.label-schema.vcs-url": "https://github.com/elastic/elasticsearch",
"org.label-schema.vendor": "Elastic",
"org.label-schema.version": "7.1.0"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "087bbb8b4469e2a5ac35aee69b62c7e8db8eb6bc16acf529d437f4777586cbac",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/default",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"host": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "047831b94cd687f5e144568ac52925897a8b2f5ee21c9af7286c0afe39b3ee03",
"EndpointID": "1a2e3b823fc5d28b4ddb4ccda9c005fff2f15d439d7f65ec27fbe2587f5395d1",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
}
}
}
]
我是 运行 派生自我们使用 Ansible 的 docker_container 模块创建的 ansible 配置的命令。我们没有意识到的是,ansible 的卷声明不仅创建了绑定安装,还创建了匿名卷。结果,我们创建的上述 docker run
不一样,因为它没有创建卷,而只是创建了绑定安装。只需添加像 -v /usr/share/elasticsearch/config/elasticsearch.yml
这样的匿名卷声明即可纠正问题。
我的问题是关于我创建的 docker 运行 命令,它是 运行 完成和创建服务,但是它有 mount/volume 问题。我正在 运行 执行以下命令:
docker run -d --restart=unless-stopped --log-driver json-file --log-opt max-file="3" --log-opt max-size="15m" -m 2.875g --cpu-shares=230 --ulimit nofile=262144:262144 --ulimit memlock=-1:-1 --group-add="elasticsearch" --user="elasticsearch" --net="host" -p 192.168.56.103:9200:9200 -p 192.168.56.103:9300:9300 -v /var/qpackage/elasticsearch/repo:/usr/share/elasticsearch/repo:rw -v /etc/qpackage/elasticsearch/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:rw -v /var/qpackage/elasticsearch/data:/usr/share/elasticsearch/data:rw -v /etc/qpackage/elasticsearch/conf/jvm.options:/usr/share/elasticsearch/config/jvm.options:rw -e "SERVICE_9200_NAME=elasticsearch" -e "SERVICE_9300_NAME=elasticsearch-node" --name elasticsearch-1_log_elasticsearch cp-elasticsearch:7.1.ox
它似乎 运行 非常好。但是,当我执行 docker inspect
时,我注意到当我放置在命令中的卷正在安装并且绑定正确时,检查还显示卷为空。这是不正确的行为。卷应该显示。
当前结果
"Volumes": null,
预期结果
"Volumes": {
"/usr/share/elasticsearch/config/elasticsearch.yml": {},
"/usr/share/elasticsearch/config/jvm.options": {},
"/usr/share/elasticsearch/data": {},
"/usr/share/elasticsearch/repo": {}
},
我可能做错了什么?
完全Docker检查
[root@localhost tmp]# docker inspect elasticsearch-1_log_elasticsearch
[
{
"Id": "be782ca624a468e30dd8c79748ef5406781134c3b6f93450b3b3f425af701301",
"Created": "2019-11-18T21:48:34.243146943Z",
"Path": "/usr/local/bin/docker-entrypoint.sh",
"Args": [
"eswrapper"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 18111,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-11-18T21:48:34.645908733Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:6e4f392617213267be91ed63bcd83a425425ed825cf0ab1f346d55375e48d91b",
"ResolvConfPath": "/var/qpackage/docker/containers/be782ca624a468e30dd8c79748ef5406781134c3b6f93450b3b3f425af701301/resolv.conf",
"HostnamePath": "/var/qpackage/docker/containers/be782ca624a468e30dd8c79748ef5406781134c3b6f93450b3b3f425af701301/hostname",
"HostsPath": "/var/qpackage/docker/containers/be782ca624a468e30dd8c79748ef5406781134c3b6f93450b3b3f425af701301/hosts",
"LogPath": "/var/qpackage/docker/containers/be782ca624a468e30dd8c79748ef5406781134c3b6f93450b3b3f425af701301/be782ca624a468e30dd8c79748ef5406781134c3b6f93450b3b3f425af701301-json.log",
"Name": "/elasticsearch-1_log_elasticsearch",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/etc/qpackage/elasticsearch/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml",
"/var/qpackage/elasticsearch/data:/usr/share/elasticsearch/data",
"/etc/qpackage/elasticsearch/conf/jvm.options:/usr/share/elasticsearch/config/jvm.options",
"/var/qpackage/elasticsearch/repo:/usr/share/elasticsearch/repo"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {
"max-file": "3",
"max-size": "15m"
}
},
"NetworkMode": "host",
"PortBindings": {
"9200/tcp": [
{
"HostIp": "192.168.56.103",
"HostPort": "9200"
}
],
"9300/tcp": [
{
"HostIp": "192.168.56.103",
"HostPort": "9300"
}
]
},
"RestartPolicy": {
"Name": "unless-stopped",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": [
"elasticsearch"
],
"IpcMode": "shareable",
"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": 230,
"Memory": 3087007744,
"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,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 6174015488,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": [
{
"Name": "nofile",
"Hard": 262144,
"Soft": 262144
},
{
"Name": "memlock",
"Hard": -1,
"Soft": -1
}
],
"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/qpackage/docker/overlay2/f23fc0453e6ef6309612864951ffa3d279dd1197a9f2cb5e27fb7884c16eba69-init/diff:/var/qpackage/docker/overlay2/cc295c456ff0d7a6e33e62578915d4b2dfaec5778e3c7c95a15862333f2ddc87/diff:/var/qpackage/docker/overlay2/baa3e9c814aa237120bbd1668a8dfec75444e3d44ec46afdaf818b03d0584bb6/diff:/var/qpackage/docker/overlay2/ac48075afe8ae211844285573419bc9e08b92b89877deca5b10eed7f071fd43c/diff:/var/qpackage/docker/overlay2/b1395bb3de16587b201eceaa1468951c1224fcd37d3e49ff012954fa0e621836/diff:/var/qpackage/docker/overlay2/a2ac251b148df5aba19addea36ecd85b7b45a5590740684ae928586f55a93fdc/diff:/var/qpackage/docker/overlay2/0cb5d6a8739367e5eab2b071f5ec3f4cb6e4d62b4d94a4919635ec05e7a6198f/diff:/var/qpackage/docker/overlay2/67657868ee478d3cb47093c67d1824eb873e2628840486bb63aef7eee29652bd/diff:/var/qpackage/docker/overlay2/108ed1526882b849cf3991c8177b7389e84da4b9a48828f43b08351b6c69ddf0/diff",
"MergedDir": "/var/qpackage/docker/overlay2/f23fc0453e6ef6309612864951ffa3d279dd1197a9f2cb5e27fb7884c16eba69/merged",
"UpperDir": "/var/qpackage/docker/overlay2/f23fc0453e6ef6309612864951ffa3d279dd1197a9f2cb5e27fb7884c16eba69/diff",
"WorkDir": "/var/qpackage/docker/overlay2/f23fc0453e6ef6309612864951ffa3d279dd1197a9f2cb5e27fb7884c16eba69/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/etc/qpackage/elasticsearch/conf/elasticsearch.yml",
"Destination": "/usr/share/elasticsearch/config/elasticsearch.yml",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/var/qpackage/elasticsearch/data",
"Destination": "/usr/share/elasticsearch/data",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/etc/qpackage/elasticsearch/conf/jvm.options",
"Destination": "/usr/share/elasticsearch/config/jvm.options",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/var/qpackage/elasticsearch/repo",
"Destination": "/usr/share/elasticsearch/repo",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "localhost.localdomain",
"Domainname": "",
"User": "elasticsearch",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"9200/tcp": {},
"9300/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"SERVICE_9200_NAME=elasticsearch",
"SERVICE_9300_NAME=elasticsearch-node",
"PATH=/usr/share/elasticsearch/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"ELASTIC_CONTAINER=true"
],
"Cmd": [
"eswrapper"
],
"ArgsEscaped": true,
"Image": "cp-elasticsearch:7.1.ox",
"Volumes": null,
"WorkingDir": "/usr/share/elasticsearch",
"Entrypoint": [
"/usr/local/bin/docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {
"license": "Elastic License",
"org.label-schema.build-date": "20190305",
"org.label-schema.license": "GPLv2",
"org.label-schema.name": "elasticsearch",
"org.label-schema.schema-version": "1.0",
"org.label-schema.url": "https://www.elastic.co/products/elasticsearch",
"org.label-schema.vcs-url": "https://github.com/elastic/elasticsearch",
"org.label-schema.vendor": "Elastic",
"org.label-schema.version": "7.1.0"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "087bbb8b4469e2a5ac35aee69b62c7e8db8eb6bc16acf529d437f4777586cbac",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/default",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"host": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "047831b94cd687f5e144568ac52925897a8b2f5ee21c9af7286c0afe39b3ee03",
"EndpointID": "1a2e3b823fc5d28b4ddb4ccda9c005fff2f15d439d7f65ec27fbe2587f5395d1",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
}
}
}
]
我是 运行 派生自我们使用 Ansible 的 docker_container 模块创建的 ansible 配置的命令。我们没有意识到的是,ansible 的卷声明不仅创建了绑定安装,还创建了匿名卷。结果,我们创建的上述 docker run
不一样,因为它没有创建卷,而只是创建了绑定安装。只需添加像 -v /usr/share/elasticsearch/config/elasticsearch.yml
这样的匿名卷声明即可纠正问题。