Check if the specified host path exists and is the expected type

这是我的docker目录挂载命令,其目的是为了达到修改linux上的文件同步到容器上,从而实现修改容器的配置文件。
主要错误:unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.

 docker run -di --name=elasticsearch -p9200:9200 -p9300:9300 -v /usr/share/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml de05e10fa879

命令执行后报错:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/usr/share/elasticsearch.yml\\\" to rootfs \\\"/var/lib/docker/devicemapper/mnt/e45ab0cdcfb0a2c48a6c25607489a072a80d786fd9cbad871eb71c09ce523801/rootfs\\\" at \\\"/var/lib/docker/devicemapper/mnt/e45ab0cdcfb0a2c48a6c25607489a072a80d786fd9cbad871eb71c09ce523801/rootfs/usr/share/elasticsearch/config/elasticsearch.yml\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.

他的意思是说你的/usr/share/elasticsearch.yml是目录,不能挂载,你可以把/usr/share/elasticsearch.yml删除后,创建一个文本文件(touch elasticsearch.yml),再次执行挂载命令即可.

你可能感兴趣的:(docker目录挂载)