V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
GoodRui
V2EX  ›  Docker

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

  •  
  •   GoodRui · 2022-02-26 11:27:52 +08:00 · 1990 次点击
    这是一个创建于 761 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

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

    是用

    command: 
    	- it
    

    这样吗?

    7 条回复    2022-02-26 15:55:34 +08:00
    runking
        2
    runking  
       2022-02-26 11:41:35 +08:00   ❤️ 4
    https://www.composerize.com

    这个可以直接转换
    also24
        3
    also24  
       2022-02-26 14:54:07 +08:00
    @runking #2
    但是对于楼主给的例子,会直接忽略掉 -it 参数
    amrnxcdt
        4
    amrnxcdt  
       2022-02-26 15:07:00 +08:00   ❤️ 1
    -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
        5
    GoodRui  
    OP
       2022-02-26 15:28:13 +08:00
    @also24
    @runking
    感谢两位热心 v 友,#1 让我明白了原理,#2 找到了好用捷径!
    GoodRui
        6
    GoodRui  
    OP
       2022-02-26 15:30:41 +08:00
    @also24 这个命令是这个 speedtest 的官方给的启动方式啊...具体还不理解为什么加-it...
    also24
        7
    also24  
       2022-02-26 15:55:34 +08:00
    @GoodRui #6
    我…………

    我本来想发 2 楼的站的,测试了一下发现会忽略 -it 参数,还以为你是强需求,于是贴了 1 楼的链接……
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3286 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 13:11 · PVG 21:11 · LAX 06:11 · JFK 09:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.