在 Docker Alpine 容器中启动 shell

编程入门 行业动态 更新时间:2024-10-22 18:48:41
本文介绍了在 Docker Alpine 容器中启动 shell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

要为 Ubuntu 映像启动交互式 shell,我们可以运行:

To start an interactive shell for the Ubuntu image we can run:

ole@T:~$ docker run -it --rm ubuntu root@1a6721e1fb64:/# ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var

但是当为 Alpine Docker 映像运行时,结果如下:

But when this is run for the Alpine Docker image, the following results:

ole@T:~$ docker run -it --rm alpine Error response from daemon: No command specified

在 Alpine 基础容器中启动交互式 shell 的命令是什么?

What is the command for starting an interactive shell in an Alpine base container?

推荐答案

ole@T:~$ docker run -it --rm alpine /bin/ash (inside container) / #

上面使用的选项:

  • /bin/ash 是 Ash (Almquist Shell) 由 BusyBox 提供
  • --rm 容器退出时自动移除(docker run --help)
  • -i 交互模式(即使没有附加也保持STDIN打开)
  • -t分配一个伪TTY
  • /bin/ash is Ash (Almquist Shell) provided by BusyBox
  • --rm Automatically remove the container when it exits (docker run --help)
  • -i Interactive mode (Keep STDIN open even if not attached)
  • -t Allocate a pseudo-TTY

更多推荐

在 Docker Alpine 容器中启动 shell

本文发布于:2023-11-17 04:42:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608869.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:容器   Docker   Alpine   shell

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!