码头运行< IMAGE> <多个命令> [英] docker run <IMAGE> <MULTIPLE COMMANDS>

查看:139
本文介绍了码头运行< IMAGE> <多个命令>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行这样的MULTIPLE命令。

  docker run image cd / path / to / somewhere& &安培; python a.py 

但是,这给了我没有这样的文件或目录的错误,因为它被解释为...

 docker run image cd / path / to / athere&& python a.py

似乎需要一些ESCAPE字符,如或()。



所以我也试过

  docker run imagecd / path / to / someplace&& python a.py
docker run image(cd / path / to / somewhere&& python a.py)
pre>

但这些没有起作用。



我搜索过 Docker Run Reference ,但没有找到关于ESCAPE字符的任何提示。

解决方案

要在docker中运行多个命令,请使用 / bin / bash -c 和分号; p>

  docker run image / bin / bash -ccd / path / to / athere; python a.py


I'm trying to run MULTIPLE commands like this.

docker run image cd /path/to/somewhere && python a.py

But this gives me "No such file or directory" error because it is interpreted as...

"docker run image cd /path/to/somewhere" && "python a.py"

It seems that some ESCAPE characters like "" or () are needed.

So I also tried

docker run image "cd /path/to/somewhere && python a.py"
docker run image (cd /path/to/somewhere && python a.py)

but these didn't work.

I have searched for Docker Run Reference but have not find any hints about ESCAPE characters.

解决方案

To run multiple commands in docker, use /bin/bash -c and semicolon ;

docker run image /bin/bash -c "cd /path/to/somewhere; python a.py"

这篇关于码头运行< IMAGE> <多个命令>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆