问题描述
下面是我的代码:
docker container run -it ubuntu /bin/bash -c "touch /root/test.txt"
我想要的是在主机上创建此文件。有人可以帮我吗?
解决方法
一种选择是从容器中的主机挂载目录。触摸容器内创建挂载位置的.txt文件。
此示例将在工作目录的docker主机上创建test.txt
文件:
docker run -it -v $(pwd):/root/mout-from-host ubuntu /bin/bash -c "touch /root/mout-from-host/test.txt"
ls
test.txt <<--file on host,created by the container