GoodRui
V2EX  ›  Docker

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

  •  
  •   GoodRui · Feb 26, 2022 · 2787 views
    This topic created in 1542 days ago, the information mentioned may be changed or developed.

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

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

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

    是用

    command: 
    	- it
    

    这样吗?

    7 replies    2022-02-26 15:55:34 +08:00
    runking
        2
    runking  
       Feb 26, 2022   ❤️ 4
    https://www.composerize.com

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

    我本来想发 2 楼的站的,测试了一下发现会忽略 -it 参数,还以为你是强需求,于是贴了 1 楼的链接……
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   987 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 19:35 · PVG 03:35 · LAX 12:35 · JFK 15:35
    ♥ Do have faith in what you're doing.