【Docker】docker挂在文件报错:container_linux.go:247......not a directory

执行容器启动命令:

 

[root@localhost conf]# docker run --name iwsactivemq -p 61617:61616 -p 8162:8161 -p 1884:1883  -v /home/iws/activmemq/conf/activemq.xml:/opt/activemq/conf/activemq.xml  -v /home/iws/iws-logs/activemq/logs:/data/activemq --restart=always -d iws:activemq
3ecdf4cebd230f313358b9f4965b46585a2ca1570da26109c4e34302a2715b7e

报错:

docker: Error response from daemon: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"process_linux.go:359: container init caused \\\"rootfs_linux.go:53: mounting \\\\\\\"/home/iws/activmemq/conf/activemq.xml\\\\\\\" to rootfs \\\\\\\"/var/lib/docker/devicemapper/mnt/1bac9274ba8dc64a778098609659f0a6b5a2873848c48a2cff8b301c8c7ff976/rootfs\\\\\\\" at \\\\\\\"/var/lib/docker/devicemapper/mnt/1bac9274ba8dc64a778098609659f0a6b5a2873848c48a2cff8b301c8c7ff976/rootfs/opt/activemq/conf/activemq.xml\\\\\\\" caused \\\\\\\"not a directory\\\\\\\"\\\"\"\n".

 

解决方案:

1、去掉activemq.xml挂载后启动

[root@localhost conf]# docker run --name iwsactivemq -p 61617:61616 -p 8162:8161 -p 1884:1883 -v /home/iws/iws-logs/activemq/logs:/data/activemq --restart=always -d iws:activemq
ce907efb8d4b7b7ce818aa6808ea3e10eb0ab2659021624f060000dfd5f07495

启动成功

2、将容器内的activemq.xml复制到宿主机挂载目录

[root@localhost conf]# docker cp ce907efb8d4b:/opt/activemq/conf/activemq.xml ./

3、删掉第一步的容器

4、重新设置挂载文件并启动:

[root@localhost conf]# docker run --name iwsactivemq -p 61617:61616 -p 8162:8161 -p 1884:1883  -v /home/iws/activmemq/conf/activemq.xml:/opt/activemq/conf/activemq.xml  -v /home/iws/iws-logs/activemq/logs:/data/activemq --restart=always -d iws:activemq
1be2efcea9bdf460437b3ab798c5f0421550c13182d534227e26122d250b2d08

启动成功!

欢迎关注公众号:

【Docker】docker挂在文件报错:container_linux.go:247......not a directory_第1张图片

你可能感兴趣的:(Docker)