Skip to content

sample-app example: database container failed to start up due to permission error while selinux is enabled #1589

Closed

Description

@xjvs

I can reproduce it by steps:

# getenforce 
Enforcing

# docker run -d -e MYSQL_USER=test -e MYSQL_PASSWORD=test -e MYSQL_DATABASE=test openshift/mysql-55-centos7
e74e0a43d051d16e45eb0ef3f0372cedc27654b61c3116fe6a6a22631194f8a0

# docker logs e74e0a43d051d16e45eb0ef3f0372cedc27654b61c3116fe6a6a22631194f8a0

Running mysql_install_db
mkdir: cannot create directory '/var/lib/mysql/data/mysql': Permission denied
chmod: cannot access '/var/lib/mysql/data/mysql': No such file or directory
mkdir: cannot create directory '/var/lib/mysql/data/test': Permission denied
chmod: cannot access '/var/lib/mysql/data/test': No such file or directory
Installing MySQL system tables...
150403  6:44:44 [Warning] Can't create test file /var/lib/mysql/data/e74e0a43d051.lower-test
150403  6:44:44 [Warning] Can't create test file /var/lib/mysql/data/e74e0a43d051.lower-test
ERROR: 1049  Unknown database 'mysql'
150403  6:44:44 [ERROR] Aborting

150403  6:44:44 [Note] /opt/rh/mysql55/root/usr/libexec/mysqld: Shutdown complete


Installation of system tables failed!  Examine the logs in
/var/lib/mysql/data for more information.

You can try to start the mysqld daemon with:

    shell> su -s /bin/bash - mysql -c 'scl enable mysql55 -- /opt/rh/mysql55/root/usr/libexec/mysqld --skip-grant --general-log &'

and use the command line tool /opt/rh/mysql55/root/usr/bin/mysql
to connect to the mysql database and look at the grant tables:

    shell> scl enable mysql55 -- mysql -u root mysql
    mysql> show tables

Try 'scl enable mysql55 -- mysqld --help' if you have problems with paths.  Using --log
gives you a log in /var/lib/mysql/data that may be helpful.

Please consult the MySQL manual section
'Problems running mysql_install_db', and the manual section that
describes problems on your OS.  Another information source are the
MySQL email archives available at http://lists.mysql.com/.

Please check all of the above before submitting a bug report
at http://bugs.mysql.com/

selinux denials:

type=NETFILTER_CFG msg=audit(1428043483.940:482): table=filter family=2 entries=0
type=NETFILTER_CFG msg=audit(1428043483.940:482): table=nat family=2 entries=0
type=SYSCALL msg=audit(1428043483.940:482): arch=c000003e syscall=56 success=yes exit=11419 a0=6c020011 a1=0 a2=0 a3=0 items=0 ppid=1 pid=7400 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="docker" exe="/usr/bin/docker" subj=system_u:system_r:docker_t:s0 key=(null)
type=ANOM_PROMISCUOUS msg=audit(1428043483.974:483): dev=veth50a0858 prom=256 old_prom=0 auid=4294967295 uid=0 gid=0 ses=4294967295
type=SYSCALL msg=audit(1428043483.974:483): arch=c000003e syscall=16 success=yes exit=0 a0=40 a1=89a2 a2=7fdb14ee69b4 a3=0 items=0 ppid=1 pid=2919 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="docker" exe="/usr/bin/docker" subj=system_u:system_r:docker_t:s0 key=(null)
type=AVC msg=audit(1428043484.034:484): avc:  denied  { create } for  pid=11450 comm="mkdir" name="mysql" scontext=system_u:system_r:svirt_lxc_net_t:s0:c582,c805 tcontext=system_u:object_r:docker_var_lib_t:s0 tclass=dir
type=SYSCALL msg=audit(1428043484.034:484): arch=c000003e syscall=83 success=no exit=-13 a0=7fff34452ce7 a1=1ff a2=1ff a3=7fff34452240 items=0 ppid=11432 pid=11450 auid=4294967295 uid=27 gid=27 euid=27 suid=27 fsuid=27 egid=27 sgid=27 fsgid=27 tty=(none) ses=4294967295 comm="mkdir" exe="/usr/bin/mkdir" subj=system_u:system_r:svirt_lxc_net_t:s0:c582,c805 key=(null)
type=AVC msg=audit(1428043484.036:485): avc:  denied  { create } for  pid=11452 comm="mkdir" name="test" scontext=system_u:system_r:svirt_lxc_net_t:s0:c582,c805 tcontext=system_u:object_r:docker_var_lib_t:s0 tclass=dir
type=SYSCALL msg=audit(1428043484.036:485): arch=c000003e syscall=83 success=no exit=-13 a0=7fff7e798ce8 a1=1ff a2=1ff a3=7fff7e7979e0 items=0 ppid=11432 pid=11452 auid=4294967295 uid=27 gid=27 euid=27 suid=27 fsuid=27 egid=27 sgid=27 fsgid=27 tty=(none) ses=4294967295 comm="mkdir" exe="/usr/bin/mkdir" subj=system_u:system_r:svirt_lxc_net_t:s0:c582,c805 key=(null)
type=AVC msg=audit(1428043484.055:486): avc:  denied  { create } for  pid=11456 comm="mysqld" name="e74e0a43d051.lower-test" scontext=system_u:system_r:svirt_lxc_net_t:s0:c582,c805 tcontext=system_u:object_r:docker_var_lib_t:s0 tclass=file
type=SYSCALL msg=audit(1428043484.055:486): arch=c000003e syscall=2 success=no exit=-13 a0=7fffa21e99d0 a1=42 a2=1b6 a3=fffffffe items=0 ppid=11432 pid=11456 auid=4294967295 uid=27 gid=27 euid=27 suid=27 fsuid=27 egid=27 sgid=27 fsgid=27 tty=(none) ses=4294967295 comm="mysqld" exe="/opt/rh/mysql55/root/usr/libexec/mysqld" subj=system_u:system_r:svirt_lxc_net_t:s0:c582,c805 key=(null)
type=AVC msg=audit(1428043484.055:487): avc:  denied  { create } for  pid=11456 comm="mysqld" name="e74e0a43d051.lower-test" scontext=system_u:system_r:svirt_lxc_net_t:s0:c582,c805 tcontext=system_u:object_r:docker_var_lib_t:s0 tclass=file
type=SYSCALL msg=audit(1428043484.055:487): arch=c000003e syscall=2 success=no exit=-13 a0=7fffa21e99d0 a1=42 a2=1b6 a3=fffffffe items=0 ppid=11432 pid=11456 auid=4294967295 uid=27 gid=27 euid=27 suid=27 fsuid=27 egid=27 sgid=27 fsgid=27 tty=(none) ses=4294967295 comm="mysqld" exe="/opt/rh/mysql55/root/usr/libexec/mysqld" subj=system_u:system_r:svirt_lxc_net_t:s0:c582,c805 key=(null)
type=ANOM_PROMISCUOUS msg=audit(1428043484.061:488): dev=veth50a0858 prom=0 old_prom=256 auid=4294967295 uid=0 gid=0 ses=4294967295

As you see in the docker run command line, I didn't mount any directory from host to that container, so I'm wondering why there are denials from host. How can I fix this without disabling selinux?

Activity

  1. sdodson commented on Apr 15, 2015

    @sdodson
    Member

    @xjvs This shouldn't be an issue using docker-1.5. Can you verify you're using docker-1.5?

  2. xjvs commented on Apr 16, 2015

    @xjvs
    Author

    @sdodson I believe you're right, I was using docker 1.4, and I just confirmed this issue doesn't happen with docker 1.6.

  3. added
    kind/bug
    on May 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/securitykind/bugpriority/P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions