• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Unable to run NGINX Docker due to “13: Permission denied”

by admin

The Problem

The NGINX docker container was started using the below command:

# docker run --detach --name nginx_server nginx
4ffbcd5ee796b8cce3f2c6ed4cce8927d2b13a040af07b36f7a866b2157290e8

But user failed to get connection to the NGINX server. Upon troubleshooting user found below error logs:

# tail -f /var/log/audit/audit.log
type=AVC msg=audit(1565283160.116:316): avc: denied { write } for pid=2387 comm="nginx" name="nginx" dev="dm-0" ino=140648937 scontext=system_u:system_r:container_t:s0:c345,c550 tcontext=system_u:object_r:container_share_t:s0 tclass=dir permissive=0
type=SYSCALL msg=audit(1565283160.116:316): arch=c000003e syscall=83 success=no exit=-13 a0=56247859585f a1=1c0 a2=0 a3=8 items=0 ppid=2371 pid=2387 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="nginx" exe="/usr/sbin/nginx" subj=system_u:system_r:container_t:s0:c345,c550 key=(null)
# docker logs nginx_server
2019/08/08 16:52:40 [emerg] 1#1: mkdir() "/var/cache/nginx/client_temp" failed (13: Permission denied)
nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed (13: Permission denied)

The Solution

AVC denial messages indicates container_t is not a permissive domain, therefore is not possible to write (13: Permission denied). In order to resolve this issue, add container_t in the SELinux.

# semanage permissive -a container_t
# semodule -l | grep permissive
permissive_container_t (null)
permissivedomains (null)

Try again to run the nginx container using -p option. With -p, it is possible to redirect the port from the docker to the host(ensure firewall is properly configured in the host).

# docker run --detach --name nginx_server -p 8080:80 nginx
2ce7b13f17c8aeaaa0e6f434ce47a16f6ed7bf94affb7f75381636fe7fdf496c

Verify if the docker is running:

# docker ps -a
CONTAINER ID   IMAGE   COMMAND                   CREATED         STATUS         PORTS                  NAMES
2ce7b13f17c8   nginx   "nginx -g 'daemon of…"    3 seconds ago   Up 3 seconds   0.0.0.0:8080->80/tcp   nginx_server

Connect to NGINX container and verify the nginx version.

# docker exec nginx_server nginx -v
nginx version: nginx/1.17.2

Filed Under: DevOps, Docker

Some more articles you might also be interested in …

  1. “su: Authentication failure” – in Docker
  2. Set up Jupyter Notebook in VS Code for Data Science
  3. How To Get Information About a Container In Docker
  4. Beginners Guide to Using “trap” to Catch Signals and Handle Errors in Shell Script
  5. How to Trace Python Scripts using trace.py
  6. Run Docker as a non-root user
  7. How to install docker on CentOS / RHEL / Fedora
  8. 10 Sed (Stream Editor) Command Examples
  9. “Error: Could Not Find A Ready Tiller Pod” – helm error
  10. How to use “break” and “continue” statements in shell scripts

You May Also Like

Primary Sidebar

Recent Posts

  • qemu-system-x86_64: command not found
  • timedatectl: command not found
  • mpirun.openmpi: command not found
  • startkde: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright