執行容器啟動命令:
[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:activemq3ecdf4cebd230f313358b9f4965b46585a2ca1570da26109c4e34302a2715b7e
報錯:
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:activemqce907efb8d4b7b7ce818aa6808ea3e10eb0ab2659021624f060000dfd5f07495
啟動成功
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:activemq1be2efcea9bdf460437b3ab798c5f0421550c13182d534227e26122d250b2d08
啟動成功。