What I have so far:
cat Dockerfile
FROM centos:7 AS env
RUN yum update -y
RUN yum install -y centos-release-scl
RUN yum install -y devtoolset-9
RUN echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc
SHELL ["/bin/bash", "--login", "-c"]
RUN gcc --version
So you must:
Add the source stuff in a bashrc
note: On Centos it's/etc/bashrcwhile on ubuntu it's/etc/bash.bashrcUpdate the docker default shell to be bash AND to "load" the bashrc using
--login
Output
docker build .
Sending build context to Docker daemon 4.096kB
Step 1/32 : FROM centos:7 AS env
---> 8652b9f0cb4c
Step 2/32 : RUN yum update -y
---> Using cache
---> a2bb269cd8dc
Step 3/32 : RUN yum install -y centos-release-scl
---> Using cache
---> 1184e26c71cf
Step 4/32 : RUN yum install -y devtoolset-9
---> Using cache
---> e678665d2a4e
Step 5/32 : RUN echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc
---> Using cache
---> fe1745d4ca87
Step 6/32 : SHELL ["/bin/bash", "--login", "-c"]
---> Running in 2dd7955f4487
Removing intermediate container 2dd7955f4487
---> 3cf4835bf680
Step 7/32 : RUN gcc --version
---> Running in b5de3266d607
gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
...
What won't work
Test 1
RUN scl enable devtoolset-9 bash
RUN gcc --version | head -1
each RUN is a new shell so the sub-bash is lost on the second line.
Test 2
RUN source /opt/rh/devtoolset-9/enable && gcc --version | head -1
RUN gcc --version | head -1
Here again the source is only for the first RUN shell command but will be lost...
Test 3
This may work but with potential unexpected behaviour
ENV PATH=/opt/rh/devtoolset-9/root/bin:$PATH
RUN gcc --version | head -1
here we only "fix" the PATH variable but if you look at the /opt/rh/devtoolset-9/enable script there is so more to do than only updating the PATH...
What I have so far:
cat Dockerfile
FROM centos:7 AS env
RUN yum update -y
RUN yum install -y centos-release-scl
RUN yum install -y devtoolset-9
RUN echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc
SHELL ["/bin/bash", "--login", "-c"]
RUN gcc --version
So you must:
Add the source stuff in a bashrc
note: On Centos it's/etc/bashrcwhile on ubuntu it's/etc/bash.bashrcUpdate the docker default shell to be bash AND to "load" the bashrc using
--login
Output
docker build .
Sending build context to Docker daemon 4.096kB
Step 1/32 : FROM centos:7 AS env
---> 8652b9f0cb4c
Step 2/32 : RUN yum update -y
---> Using cache
---> a2bb269cd8dc
Step 3/32 : RUN yum install -y centos-release-scl
---> Using cache
---> 1184e26c71cf
Step 4/32 : RUN yum install -y devtoolset-9
---> Using cache
---> e678665d2a4e
Step 5/32 : RUN echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc
---> Using cache
---> fe1745d4ca87
Step 6/32 : SHELL ["/bin/bash", "--login", "-c"]
---> Running in 2dd7955f4487
Removing intermediate container 2dd7955f4487
---> 3cf4835bf680
Step 7/32 : RUN gcc --version
---> Running in b5de3266d607
gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
...
What won't work
Test 1
RUN scl enable devtoolset-9 bash
RUN gcc --version | head -1
each RUN is a new shell so the sub-bash is lost on the second line.
Test 2
RUN source /opt/rh/devtoolset-9/enable && gcc --version | head -1
RUN gcc --version | head -1
Here again the source is only for the first RUN shell command but will be lost...
Test 3
This may work but with potential unexpected behaviour
ENV PATH=/opt/rh/devtoolset-9/root/bin:$PATH
RUN gcc --version | head -1
here we only "fix" the PATH variable but if you look at the /opt/rh/devtoolset-9/enable script there is so more to do than only updating the PATH...
You may give it a try using the below steps if that may help: Download the latest package from http://ftp.gnu.org/gnu/gcc/gcc-9.2.0/
wget http://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz
Extract the files using the steps below:
tar -xzvf gcc-9.20.tar.gz
cd gcc-9.2.0
Build a configuration using the below,
./configure
Compile the installation using make and then make install.
make
make install
In your console output it says: Maybe run: yum groups mark install (see man yum)—did you do this?
Try running the following commands:
yum groups mark install "Development Tools"
yum groups mark convert "Development Tools"
yum groupinstall "Development Tools"
Reference: RedHat Customer Portal discussion
Try:
yum group list
To see if yum can find the Development Tools under Available Groups.
If it fails, try:
yum clean all
yum group list
And see if it can find it. If it still fails, you might not have the correct mirrors enabled to resolve it.
try the clean command again and then:
yum --disablerepo=\* --enablerepo=base,updates group list
If you can find it. Great! Install with:
yum --disablerepo=\* --enablerepo=base,updates groupinstall "Development Tools"
If not so, can you give us the output of:
yum repolist all
EDIT:
Thank you for the output.
I found an article which state the following: "To install the CentOS Development tools, you will need to be able to connect to your Virtual Server using SSH, and work as the root user."
Try switching to user "root" (if you don't know the root login credentials, you can try sudo su. sudo also might work but I see you already have tried that...) and running the above commands.
Lastly, you can try and enable these "sources" repos:
- CentOS-7 - Base Sources
- CentOS-7 - Extras Sources
- CentOS-7 - Updates Sources
And than running yum update followed by groupinstall.
Let me know if that doesn't work. Good luck!
On CentOS I can do yum install devtoolset-8 followed by scl enable devtoolset-8 bash so that my paths are setup to use GCC et al packaged with that development toolset.
Is there an equivalent in AlmaLinux?