95

I am trying to install Docker CE on RHEL using this link. This is my RHEL version:

Red Hat Enterprise Linux Server release 7.3 (Maipo)

When I execute this:

sudo yum -y install docker-ce

I am getting this error:

Error: Package: docker-ce-17.06.0.ce-1.el7.centos.x86_64 (docker-ce-stable)
           Requires: container-selinux >= 2.9
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

I tried using --skip-broken and rpm -Va --nofiles --nodigest but again getting the same error. Please let me know how to resolve this issue and install Docker CE in RHEL 7.3.

Kirk Broadhurst
  • 27,836
  • 16
  • 104
  • 169
user182944
  • 7,897
  • 33
  • 108
  • 174
  • 1
    If you want to just make it work (knowing that you are using an unsupported rpm), look at https://stackoverflow.com/a/45033117/3370010 – waternova Jul 27 '17 at 22:42

21 Answers21

79

The container-selinux package is available from the rhel-7-server-extras-rpms channel. You can enable it using:

subscription-manager repos --enable=rhel-7-server-extras-rpms

Sources for the package have been exported to git.centos.org, too, so you could rebuild it yourself using mock:

(This is not a programming question, so you should use one of the other sites.)

Florian Weimer
  • 32,022
  • 3
  • 48
  • 92
  • I dont have an active subscription. Any alternative way? – user182944 Jul 24 '17 at 08:07
  • You can use `mock` to build the package from the [sources on `git.centos.org`](https://git.centos.org/summary/rpms!container-selinux.git). `mock` itself is in EPEL, but it probably depends on some packages from Red Hat Enterprise Linux you have not installed yet, so you need to cross-grade to CentOS first. – Florian Weimer Jul 24 '17 at 08:11
  • 3
    I get `Error: 'rhel-7-server-extras-rpms' does not match a valid repository ID.` – prayagupa Nov 26 '18 at 05:12
  • @prayagupd This looks like an unrelated subscription management issue. You should open a support case. – Florian Weimer Nov 29 '18 at 16:31
  • @prayagupd it's too late to respond but it's because you might not be using RHEL server edition you might be using workstation. – Anurag Sinha Jan 16 '19 at 08:21
  • I fixed by installing selinux `sudo yum -y install http://vault.centos.org/centos/7.3.1611/extras/x86_64/Packages/container-selinux-2.9-4.el7.noarch.rpm` on redhat/ amazon linux. You can find other packages as well at http://vault.centos.org/centos/7.3.1611/extras/x86_64/Packages/ – prayagupa Mar 10 '19 at 05:29
  • this worked like charm, for those who unable to get the baseurl link for this repo: `baseurl = https://cdn.redhat.com/content/dist/rhel/server/7/7Server/$basearch/extras/os` – Rajneesh Gadge Jan 23 '23 at 08:45
76

Installing the Selinux from the Centos repository worked for me:
1. Go to http://mirror.centos.org/centos/7/extras/x86_64/Packages/
2. Find the latest version for container-selinux i.e. container-selinux-2.21-1.el7.noarch.rpm
3. Run the following command on your terminal: $ sudo yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/**Add_current_container-selinux_package_here**
4. The command should looks like the following $ sudo yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.21-1.el7.noarch.rpm
Note: the container version is constantly being updated, that is why you should look for the latest version in the Centos' repository

Samir Silva
  • 769
  • 4
  • 2
  • 2
    any easy way to script something so it finds the latest version on it's own? – luker02 Mar 09 '20 at 18:07
  • Why do we have package managers like YUM if this kind of version picking is required? – Marc Sep 29 '21 at 09:58
  • Samir, you really pointed me in the right direction. I was able to get docker-ce 19.03 installed on RedHat 7.9 using a series of centos rpm installs. Believe it or not it works. container-selinux package is foundational to install containerd and docker-ce. – Charles Owen Jul 05 '23 at 17:07
59

Just install selinux latest version to fix it:
sudo yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.107-3.el7.noarch.rpm

More versions at http://mirror.centos.org/centos/7/extras/x86_64/Packages/

Older versions of 2.9: http://ftp.riken.jp/Linux/cern/centos/7/extras/x86_64/Packages/

0xMH
  • 1,825
  • 20
  • 26
Leon
  • 3,124
  • 31
  • 36
  • 4
    Thanks, this worked for me. To future googlers, copying and pasting what they have above almost certainly won't work since it's old at this point. Go to the more versions link and grab the latest version (copy link address). – rjhilgefort Jan 04 '20 at 03:38
26

Error: Package: 2:container-selinux-2.74-1.el7.noarch (rhel-7-server-extras-rpms)

Requires: selinux-policy >= 3.13.1-216.el7

Installed: selinux-policy-3.13.1-192.el7_5.6.noarch (@rhel-7-server-rpms)

selinux-policy = 3.13.1-192.el7_5.6

there is dependency issue with the container-selinux version

to fix this error on rhel 7.x i have performed the below things

1) yum install http://vault.centos.org/centos/7.3.1611/extras/x86_64/Packages/container-selinux-2.9-4.el7.noarch.rpm

2) yum install -y yum-utils device-mapper-persistent-data lvm2

3) yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

4 ) yum install docker-ce

now start the docker service

Apuri Srikanth
  • 399
  • 3
  • 6
  • yum install http://vault.centos.org/centos/7.3.1611/extras/x86_64/Packages/container-selinux-2.9-4.el7.noarch.rpm was the only way to install container-selinux. Thank you! – rogervila Oct 01 '19 at 07:56
  • It's important to remark that, before installing docker-ce, a yum update could be required depending on your version – rogervila Oct 08 '19 at 10:35
  • failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try. – Yanov Apr 15 '20 at 19:37
11

Docker CE is not supported on RHEL. Any way you are trying to get around that is not a supported way. You can see the supported platforms in the Docker Documentation. I suggest you either use a supported OS, or switch to Enterprise Edition.

Mano Marks
  • 8,761
  • 3
  • 27
  • 28
9

You have already have container-selinux installed for version 3.7 check if the following docker-ce version works for you , it did for me.

sudo yum -y install docker-ce-cli.x86_64 1:19.03.5-3.el7
oyeshetty
  • 101
  • 1
  • 5
5

Head to http://mirror.centos.org/centos/7/extras/x86_64/Packages/ and get the link to the latest container-selinux package. In my case the link was http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.68-1.el7.noarch.rpm

Head to your terminal as root and run:

yum install http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.68-1.el7.noarch.rpm

After that you can proceed to install docker:

yum install docker-ce

Moses Nandwa
  • 179
  • 2
  • 3
4

To resolve the following error I was facing to install docker-ce on RHEL-7

Error: Package: 3:docker-ce-18.09.5-3.el7.x86_64 (docker-ce-stable)
           Requires: container-selinux >= 2.9
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

Please run following command before installing latest version of docker-ce

yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.68-1.el7.noarch.rpm

Once previous command runs successfully then install docker-ce with following command

yum -y install docker-ce

once installation is done then run

systemctl start docker

Note : Run all these commands with root user

Abhishek Jain
  • 3,815
  • 2
  • 26
  • 26
  • please try http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.95-2.el7_6.noarch.rpm – suiwenfeng May 12 '19 at 15:41
3

To update container-selinux I had to install epel-release first:

Add Centos-7 repository

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

Install epel-release

yum install epel-release

Update container-selinux

yum install container-selinux
阿尔曼
  • 1,275
  • 2
  • 14
  • 18
  • http://mirrors.aliyun.com/centos/7/extras/x86_64/Packages/epel-release-7-9.noarch.rpm: [Errno 14] HTTP Error 404 - Not Found – AnneTheAgile Oct 28 '19 at 15:48
  • It is moved to http://mirrors.aliyun.com/centos/7/extras/x86_64/Packages/epel-release-7-11.noarch.rpm – 阿尔曼 Nov 03 '19 at 14:20
2

I was getting the same error Requires: container-selinux >= 2.9 on amazon ec2 instance(Rhel7)

I tried to add extra package rmp repo by executing sudo yum-config-manager --enable rhui-REGION-rhel-server-extras
but it works. followed steps from https://installdocker.blogspot.com/ and I was able to install docker.

bishtb
  • 21
  • 1
2

Try:

yum install http://vault.centos.org/centos/7.3.1611/extras/x86_64/Packages/container-selinux-2.9-4.el7.noarch.rpm

It worked for me.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Ashish Kumar
  • 524
  • 6
  • 18
  • Your answer does not add any new information. This is already answered by someone else – Ankur Aggarwal Dec 18 '18 at 09:28
  • 1
    @AnkurAggarwal when you leave moderation-related comments, you should really be more specific than "This is already answered by someone else". That's also not a valid reason; just because it's answered doesn't mean it's not allowed to add another answer, assuming it isn't blatant plagiarism and follows the general rules for SE answers. – Zoe Dec 18 '18 at 15:20
2

[SOLVED] Simple one command to fix this issue.

yum install http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.107-3.el7.noarch.rpm
VinKam
  • 43
  • 4
2

DOCKER Ce is not officialy supported on REHL to fix that run the below commands

wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.107-3.el7.noarch.rpm
sudo rpm -i container-selinux-2.107.el7.noarch.rpm

wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/slirp4netns-0.4.3-4.el7_8.x86_64.rpm



#Set up the Docker CE repository on RHEL:
sudo yum install -y yum-utils
sudo yum install -y device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
yum install docker-ce docker-ce-cli containerd.io

#Start Docker:
sudo systemctl start docker
 
#Test your Docker CE installation:
sudo docker run hello-world
G.S
  • 10,413
  • 7
  • 36
  • 52
Souad Fawzy
  • 116
  • 3
1

Update June 2019

What a dogs dinner. Unfortunately, the other answers didn't work for me.

For the most part, the official docker instructions for installing using a repository DID work.

sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

Followed by:

sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

However, I had to modify the next command as follows (adding --nobest):

sudo yum install docker-ce --nobest

Finally, check the docker client:

docker --version
Docker version 18.09.7, build 2d0083d

Note also, the above works for standard RHEL AMI on AWS, but not for the Amazon Linux AMI type. May also find referencing this github issue insightful.

Added bonus, I found the following additional commands helpful:

Start the docker daemon:

sudo systemctl start docker.service

Give the current user (in my case ec2-user - check with whoami) rights to the docker group. This avoids running everything with sudo.

sudo usermod -aG docker $USER

Now, logoff and login again as same user as before (in my case ec2-user).

At this point, everything should be working. Check the docker daemon:

docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
arcseldon
  • 35,523
  • 17
  • 121
  • 125
  • Something on Docker's side changed very recently. They now require container-selinux 2.74. This is blocking us from installing docker in centos7.4 now. – Halsafar Jul 12 '19 at 19:05
1

On CentOS7 I had to follow the third install method, get-docker.sh https://docs.docker.com/install/linux/docker-ce/centos/#install-using-the-convenience-script

AnneTheAgile
  • 9,932
  • 6
  • 52
  • 48
1

The best way to resolve this one is. Download the latest container-selinux package from http://mirror.centos.org/centos/7/extras/x86_64/Packages/ into the VM or the Machine where docker needs to be installed. Error : sometime it will ask for red hat subscription to download from repo. we can do it manually with out subscription as below Run the below command this will install dependencies manually rpm -i container-selinux-2.107-3.el7.noarch.rpm then run the yum install docker-ce

thanks Saa

Saa Satyam
  • 71
  • 1
  • 5
1

If we face issues in installing docker in an aws ec2 instance. Follow the below steps :

sudo yum update -y
sudo amazon-linux-extras install docker
sudo yum install docker
sudo service docker start
sudo systemctl enable docker
systemctl status docker

(link : https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html)

helvete
  • 2,455
  • 13
  • 33
  • 37
0

As with other answers, adding the "extras" subscribed channels to a CentOS 7 Spacewalk deployment solves this problem as well.

Charlie O
  • 9
  • 2
0

I experienced the same error while installing docker in redhat 7. Below are the steps that eventually worked. This should be applicable in centos 7 as well.

yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
sed -i 's~/rhel/~/centos/~g' /etc/yum.repos.d/docker-ce.repo
subscription-manager repos --enable=rhel-7-server-extras-rpms
yum --noplugins install docker-ce docker-ce-cli containerd.io docker-compose-plugin
systemctl start docker
systemctl status docker
systemctl enable docker
Benjamin Buch
  • 4,752
  • 7
  • 28
  • 51
Billy
  • 1
  • 1
-1

I followed many links including the official documentation, however it all ended up in this error:

Requires: container-selinux >= 2.9
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

The only way it worked for me is as follows (yum upgrade worked I guess):

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

yum upgrade docker-ce
stayingcool
  • 2,324
  • 1
  • 21
  • 24
-1

this link helped me to solve this issue

Here is the solution: For centos: try

sudo yum install --setopt=obsoletes=0 \
>    docker-ce-17.03.2.ce-1.el7.centos.x86_64 \
>    docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch

For Rhel:

sudo yum install --setopt=obsoletes=0 docker-ce-17.03.3.ce-1.el7.x86_64.rpm docker-ce-selinux-17.03.3.ce-1.el7.noarch.rpm
user_dev
  • 1,357
  • 3
  • 20
  • 46
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/22053022) – Benny Bottema Jan 28 '19 at 19:35
  • Updated the answer with explanation – user_dev Mar 09 '19 at 03:07