如何在 Dockerfile 中启动另一个 bash [英] How to start another bash in Dockerfile

查看:39
本文介绍了如何在 Dockerfile 中启动另一个 bash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想按照本教程在容器(CentOS 6.9)中将 GCC 从 4.4.7 更新到 4.7.2 如何在 CentOS 上升级 GCC.

I want to update GCC from 4.4.7 to 4.7.2 in a container(CentOS 6.9) following this tutorial How to upgrade GCC on CentOS.

在教程的最后,作者使用scl enable devtoolset-1.1 bash来启动一个新的shell,所有的环境都更新了.我写了以下 Dockerfile:

In the end of the tutorial, the author uses scl enable devtoolset-1.1 bash to launch a new shell where all the environments are updated. I write the following Dockerfile:

Run ... 
  && yum install devtoolset-1.1 
  && scl enable devtoolset-1.1 bash

但是,当我从Dockerfile生成的镜像运行容器时,发现GCC版本还是4.4.7,说明我进入的是旧shell.

However, when I run the container from the images generated by the Dockerfile, I find that the GCC version is still 4.4.7, which indicates that I enter the old shell.

虽然我通过显式定义 CC、CPP、CXX 变量成功地更新了容器中的 GCC,但我仍然想知道如何在 Dockerfile 中使用scl"命令更新 GCC.也就是说,如何在 Dockerfile 中进入一个新的 shell?

Though I success in updating GCC in the container by explicitly defining the CC, CPP, CXX variables, I still want to know how to update GCC with "scl" command in a Dockerfile. That's to say, how to enter a new shell in a Dockerfile?

提前谢谢你.^_^

推荐答案

在Dockerfile的指令中,你有SHELL

Among the directives of the Dockerfile, you have SHELL

https://docs.docker.com/engine/reference/builder/#贝壳

来自这个文档

如果需要其他 shell,例如 zsh、csh、tcsh 等,也可以在 Linux 上使用 SHELL 指令.

这篇关于如何在 Dockerfile 中启动另一个 bash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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