使用Docker Compose的交互式外壳 [英] Interactive shell using Docker Compose

查看:1026
本文介绍了使用Docker Compose的交互式外壳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用Docker Compose在容器中启动交互式shell?我已经尝试过这样的东西,在我的docker-compose.yml中:

  myapp:
image:alpine:最新
entrypoint:/ bin / sh

当我使用docker-compose启动这个容器它立即退出。有没有任何可以添加到entrypoint命令的标志,或者作为myapp的附加选项,作为交互式shell启动?



我知道有本机docker命令选项实现这个,只是好奇,如果可能只使用Docker Compose。



最好的问候,
鲍里斯

解决方案

您需要在docker-compose.yml中包含以下行:

  stdin_open:true 
tty:true

第一个对应于 docker运行中的-i ,第二个到 -t


Is there any way to start a interactive shell in a container using Docker Compose only? I've tried something like this, in my docker-compose.yml:

myapp:
  image: alpine:latest
  entrypoint: /bin/sh

When I start this container using docker-compose up it's exited immediately. Are there any flags I can add to the entrypoint command, or as and additional option to myapp, to start as interactive shell?

I know there are native docker command options to achieve this, just curious if it's possible using only Docker Compose, too.

Best regards, Boris

解决方案

You need to include the following lines in your docker-compose.yml:

stdin_open: true
tty: true

The first corresponds to -i in docker run and the second to -t.

这篇关于使用Docker Compose的交互式外壳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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