本文主要是介绍CentOS 7.2运行Docker报错Container command could not be invoked,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
使用CentOS 7.2执行docker build时,出现报错,在拉取完基础镜像,执行RUM命令时出现以下报错,
...
Step 2 : RUN yum install net-tools -y---> Running in 1afd8dcf21cf
permission denied
Container command could not be invoked.
这其实就是SELinux搞的鬼,因此需要把它关闭。
先确认系统当前selinux的状态,使用以下两个命令查看,
[root@localhost /home/docker]# getenforce
Enforcing
[root@localhost /home/docker]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
Enforcing以及sestatus命令返回结果中Current mode的enforcing表示此时selinux是开启状态,可以使用以下命令关闭它,
[root@localhost /home/docker]# setenforce 0
[root@localhost /home/docker]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
可以看到此时Current mode已经变成permissive,此时再执行docker build则无报错。
但是这种修改方式重启后就会丢失,可以通过修改/etc/sysconfig/selinux的配置,达到永久生效的目的。
vi /etc/sysconfig/selinuxSELINUX=disabled
通过将SELINUX设置为disabled即可,重启后selinux依旧保持关闭状态。
这篇关于CentOS 7.2运行Docker报错Container command could not be invoked的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!