How to start another bash in Dockerfile

前端 未结 2 826
青春惊慌失措
青春惊慌失措 2021-02-16 00:27

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.

In the end of the tutorial, the author uses <

相关标签:
2条回答
  • 2021-02-16 00:34

    Among the directives of the Dockerfile, you have SHELL

    https://docs.docker.com/engine/reference/builder/#shell

    from this doc

    The SHELL instruction can also be used on Linux should an alternate shell be required such as zsh, csh, tcsh and others.

    0 讨论(0)
  • 2021-02-16 00:44

    To expand on @user2915097's answer here is a working example using devtoolset-7 and rh-python36 instead of devtoolset-1.1

    FROM centos:7
    
    # Default version of GCC and Python
    RUN gcc --version && python --version
    
    # Install some developer style software collections with intent to
    # use newer version of GCC and Python than the OS provided
    RUN yum install -y centos-release-scl && yum install -y devtoolset-7 rh-python36
    
    # Yum installed packages but the default OS-provided version is still used.
    RUN gcc --version && python --version
    
    # Okay, change our shell to specifically use our software collections.
    # (default was SHELL [ "/bin/sh", "-c" ])
    # https://docs.docker.com/engine/reference/builder/#shell
    #
    # See also `scl` man page for enabling multiple packages if desired:
    # https://linux.die.net/man/1/scl
    SHELL [ "/usr/bin/scl", "enable", "devtoolset-7", "rh-python36" ]
    
    # Switching to a different shell has brought the new versions into scope.
    RUN gcc --version && python --version
    
    0 讨论(0)
提交回复
热议问题