docker run 参数怎么写进 docker-compose.yml 文件里?

2022-02-26 11:27:52 +08:00
 GoodRui

新手刚开始上手 docker ,在写 docker compose 的 yaml 配置文件时,

docker run -e MODE=standalone -p 80:80 -it adolfintel/speedtest

这种类似 -it 的参数,在 docker-compose.yml 配置文件里怎么表示?搜了好多资料好像也没提到...

是用

command: 
	- it

这样吗?

2052 次点击
所在节点    Docker
7 条回复
also24
2022-02-26 11:36:24 +08:00
runking
2022-02-26 11:41:35 +08:00
https://www.composerize.com

这个可以直接转换
also24
2022-02-26 14:54:07 +08:00
@runking #2
但是对于楼主给的例子,会直接忽略掉 -it 参数
amrnxcdt
2022-02-26 15:07:00 +08:00
-it 是 docker cli 的参数。https://docs.docker.com/engine/reference/commandline/run/#examples

This example runs a container named test using the debian:latest image. The -it instructs Docker to allocate a pseudo-TTY connected to the container’s stdin; creating an interactive bash shell in the container. In the example, the bash shell is quit by entering exit 13. This exit code is passed on to the caller of docker run, and is recorded in the test container’s metadata.
GoodRui
2022-02-26 15:28:13 +08:00
@also24
@runking
感谢两位热心 v 友,#1 让我明白了原理,#2 找到了好用捷径!
GoodRui
2022-02-26 15:30:41 +08:00
@also24 这个命令是这个 speedtest 的官方给的启动方式啊...具体还不理解为什么加-it...
also24
2022-02-26 15:55:34 +08:00
@GoodRui #6
我…………

我本来想发 2 楼的站的,测试了一下发现会忽略 -it 参数,还以为你是强需求,于是贴了 1 楼的链接……

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/836547

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX