简体   繁体   English

了解 Docker .Sh 文件

[英]Understanding a Docker .Sh file

The .sh file I am working with is:我正在使用的 .sh 文件是:

docker run -d --rm -it --gpus '"device=0,1,2,3"' --ipc=host -v $HOME/Folder:/Folder tr_xl_container nohup python /Path/file.py -p/Path/ |& tee $HOME/Path/log.txt

I am confused about the -v and everything after that.我对-v和之后的一切感到困惑。 Specifically, the -v $HOME/Folder:/Folder tr_xl_container section and -p/Path/ .具体来说, -v $HOME/Folder:/Folder tr_xl_container部分和-p/Path/ If someone would be able to help breakdown what those commands mean or point me to a reference that does, that would be very much appreciated.如果有人能够帮助分解这些命令的含义或将我指向一个参考,那将非常感激。 I checked Docker documentation and Linux command line documentation and did not come up with anything too helpful.我检查了 Docker 文档和 Linux 命令行文档,但没有找到任何有用的东西。

A docker run command is split up in 3 parts:一个docker run命令分为 3 个部分:

  • docker options泊坞窗选项
  • the image to run要运行的图像
  • a command for the container容器的命令

In your case -d --rm -it --gpus '"device=0,1,2,3"' --ipc=host -v $HOME/Folder:/Folder are docker options.在您的情况下-d --rm -it --gpus '"device=0,1,2,3"' --ipc=host -v $HOME/Folder:/Folder是 docker 选项。

tr_xl_container is the image name. tr_xl_container是图像名称。

nohup python /Path/file.py -p/Path/ is the command sent to the container. nohup python /Path/file.py -p/Path/是发送到容器的命令。

The last part, |& tee $HOME/Path/log.txt isn't run in the container, but takes the output from the docker run command and saves it in $HOME/Path/log.txt .最后一部分|& tee $HOME/Path/log.txt不在容器中运行,而是从docker run命令获取输出并将其保存在$HOME/Path/log.txt中。

As for -v $HOME/Folder:/Folder , it's a volume mapping or more precisely, a bind mount.至于-v $HOME/Folder:/Folder ,它是一个卷映射,或者更准确地说,是一个绑定挂载。 It creates a directory in the container with the path /Folder that is linked to the directory $Home/Folder on the host machine.它在容器中创建一个目录,其路径为/Folder ,该目录链接到主机上的目录$Home/Folder That makes files in the host directory visible inside the container and if the container does anything with files in the /Folder directory, those changes will be visible in the host directory.这使得主机目录中的文件在容器内可见,如果容器对 /Folder 目录中的文件执行任何操作,这些更改将在主机目录中可见。

The command after the image name is for the container and it's up to the container what to do with it.镜像名称后面的命令是针对容器的,它取决于容器如何处理它。 From looking at it, it looks like it runs a Python program stored in /Path/file.py in the image.从外观上看,它看起来像是在运行图像中/Path/file.py中存储的 Python 程序。 But to be sure, you'll need to know what the image does.但可以肯定的是,您需要知道图像的作用。

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

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