在 运行 Dockerfile 上提供命令行

Have command line available upon running Dockerfile

我似乎无法找到在启动 Docker 文件时如何使用命令行的确切方法。我可以在 Docker 文件中设置某个参数,它会在 Docker 容器中启动图像时提供命令行吗?

啊这是一个非常简单的解决方案

CMD ["/bin/bash"]

当你运行一个容器时你可以添加选项-it

docker run -it some/image:tag

来自docs

For interactive processes (like a shell), you must use -i -t together in order to allocate a tty for the container process. -i -t is often written -it as you’ll see in later examples. Specifying -t is forbidden when the client is receiving its standard input from a pipe, as in