docker run redis STATUS Exited (1)

1、用 docker 启动redis 

docker run --name redis -p 6379:6379 -v /data:/data -d redis

启动redis或其他组件使用docker ps -a 发现

[root@localhost ~]# docker ps -a 
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                     PORTS           
bf250c9e3ea6        redis               "docker-entrypoint..."   About a minute ago   Exited (1) 4 seconds ago

2、查看docker-redis状态

docker logs redis
[root@localhost ~]# docker logs redis
find: '.': Permission denied
chown: changing ownership of '.': Permission denied

以为是权限问题

尝试修改权限

chown -R roor /data
chmod -R 777 /data
docker start redis

仍然出现该问题

3、查找类似问题发现是防火墙问题

先临时关闭 selinux 

setenforce 0

再修改 把SELINUX改成 SELINUX=disable

vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disable
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

4、再次尝试启动docker - redis 

[root@localhost ~]# docker start redis
redis
[root@localhost ~]# docker ps -a 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                   
b016af4516e9        redis               "docker-entrypoint..."   3 minutes ago       Up 3 seconds        0.0.0.0:6379->6379/tcp  

状态为Up启动完成。

你可能感兴趣的:(docker)