title: How to start crond as non-root user in a Docker Container?
body: <p>I am using the below <code>Dockerfile</code> and <code>entrypoint.sh</code>. I need to start the <code>crond</code> service in the container as a non-root user but I get <code>Permission denied</code>. How do I start the <code>crond</code> service as a non-root user?</p>
  
  <p>I need have <code>USER</code> in <code>Dockerfile</code> as it is a mandatory admin setting in my Openshift 3 Platform.</p>
  
  <p><em>Dockerfile</em>   </p>
  
  <pre><code>FROM centos:centos7.4.1708
  RUN yum update -y &amp;&amp; yum install -y cronie &amp;&amp; rm -rf /var/lib/apt/lists/*
  RUN cd / &amp;&amp; mkdir /code
  ADD entrypoint.sh /code/
  RUN chmod -R 755 /code/entrypoint.sh
  ENTRYPOINT ["/code/entrypoint.sh"]
  RUN useradd -l -u 1001510000 -c "1001510000" 1001510000
  USER 1001510000
  CMD ["top"]
  </code></pre>
  
  <p><em>entrypoint.sh</em>   </p>
  
  <pre><code>#!/bin/bash
  echo "in the entrypoint!"
  echo "executing id"
  id
  echo "executing crond start"
  crond start
  echo "executing $@"
  $@
  </code></pre>
  
  <p><em>Error Output</em></p>
  
  <pre><code>in the entrypoint!
  executing id
  uid=1001510000(1001510000) gid=1000(1001510000) groups=1000(1001510000)
  executing crond start
  crond: can't open or create /var/run/crond.pid: Permission denied
  executing top
  </code></pre>