简体   繁体   English

docker run 无法将文件挂载到容器

[英]docker run could not mount file to container

I have checked the local files, they are exist, please help, I want to mount local configurateion to container我检查了本地文件,它们存在,请帮忙,我想将本地配置挂载到容器

sudo docker run -v /usr1/V3R002C10_BP/.m2/settings.xml:/usr/share/apache-maven-3.3.9/conf/settings.xml:rw -v /usr1/V3R002C10_BP/.sbt/repositories:/root/.sbt/repositories:rw  -v /usr1/V3R002C10_BP:/usr1/V3R002C10_BP:rw --workdir=/usr1/V3R002C10_BP/task1935/ac_bp_all --net host --name ubuntu_bash5 -i -t hub.witcloud.huawei.com/r00230944/suse11sp3:1.0.2 /bin/bash  
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:359: container init caused \"rootfs_linux.go:54: mounting \\\"/usr1/V3R002C10_BP/.sbt/repositories\\\" to rootfs \\\"/var/lib/docker/aufs/mnt/34872c92bc91fe920b846d5abff3d43ec0042fe8a1df8a1d20d03b6f24c7ff51\\\" at \\\"/var/lib/docker/aufs/mnt/34872c92bc91fe920b846d5abff3d43ec0042fe8a1df8a1d20d03b6f24c7ff51/root/.sbt/repositories\\\" caused \\\"not a directory\\\"\""
: 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.

the following are the check to be mounted files:以下是检查要挂载的文件:

root@LFG1000818717:/opt# ll /usr1/V3R002C10_BP/.m2/settings.xml
total 12
drwxrwxrwx 2 root root 4096 Jul 20 17:37 ./
drwxrwxrwx 3 root root 4096 Jul 20 16:33 ../
-rwxrwxrwx 1 root root 2226 Jul 20 17:37 settings.xml.sdn*
root@LFG1000818717:/opt# ll  /usr1/V3R002C10_BP/.sbt/repositories
total 12
drwxrwxrwx 2 root root 4096 Jul 20 17:37 ./
drwxrwxrwx 3 root root 4096 Jul 20 16:33 ../
-rwxrwxrwx 1 root root  456 Jul 20 17:37 repositories*
root@LFG1000818717:/opt# ll /usr1/V3R002C10_BP
total 28
drwxr-xr-x  7 root root 4096 Jul 20 18:07 ./
drwxr-xr-x  6 root root 4096 Jul 21 04:56 ../
drwxr-xr-x 23 root root 4096 Jul 20 18:28 ac_bp_all/
drwxr-xr-x  2 root root 4096 Jul 20 17:37 gradle/
drwxrwxrwx  3 root root 4096 Jul 20 16:33 .m2/
drwxrwxrwx  3 root root 4096 Jul 20 16:33 .sbt/
drwxr-xr-x  2 root root 4096 Jul 20 18:23 task1935/

Just use the docker cp command .只需使用docker cp命令 It copies a file from the host to a container.它将文件从主机复制到容器。 It is probably better than using docker run in this scenario.在这种情况下,它可能比使用docker run更好。

For copying files to the container:将文件复制到容器:

docker cp SRC_PATH CONTAINER:DEST_PATH

For copying files from the container to host:将文件从容器复制到主机:

docker cp CONTAINER:SRC_PATH DEST_PATH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM