的test.txt
port = 1234
host = abc.com
Run Code Online (Sandbox Code Playgroud)
test.py
port = sys.argv[1]
host = sys.argv[2]
Run Code Online (Sandbox Code Playgroud)
我想提供test.txt作为python脚本的输入:
python test.py test.txt
Run Code Online (Sandbox Code Playgroud)
因此,文本文件中的端口和主机值应作为命令行参数传递给python脚本,这些参数将被传递到脚本中的端口和主机.
如果我做 :
python test.py 1234 abc.com
参数传递给sys.argv [1]和sys.argv [2]
同样我想用txt文件读取来实现.
谢谢.
python脚本执行后,docker容器立即退出:
docker run -t -i -v /root/test.py:/test.py zookeeper python test.py(test.py启动zookeeper服务)
该命令成功但立即退出启动容器.我无法使用"docker start container id"启动容器.
手动运行"python test.py"在容器内是成功的,但在"docker run ......"期间没有.
我们可以使用带有源图像(OS)的docker文件来创建docker镜像,即
FROM rhel
Run Code Online (Sandbox Code Playgroud)
我们不希望所有应用程序泊坞窗图像中都有基本图像(centos或rhel).我们想要分离基本图像(centos或rhel)和应用程序图像,并在运行时链接它们.可能吗?
当我在没有 FROM centos或构建docker镜像时rhel,docker抱怨:"在提交前提供源图像"
我的docker文件如下所示:
MAINTAINER abc
RUN mkdir /opt/cassandra
RUN cd /opt/cassandra
RUN wget http://www.interior-dsgn.com/apache/cassandra/2.1.2/apache-cassandra-2.1.2-bin.tar.gz
RUN tar xvzf apache-cassandra-2.1.2-bin.tar.gz
RUN cd apache-cassandra-2.1.2-bin
Run Code Online (Sandbox Code Playgroud)