<p>I am trying to run a rethinkdb image on a Kubernetes cluster that has tight security measures and we must run containers as non-root, therefore I am using user 1000 to run them and I changed the Dockerfile to below:</p>

<pre><code>FROM ubuntu:18.04

RUN apt update &amp;&amp; apt install -y wget libcurl4 libprotobuf10 python3-pip

RUN wget https://github.com/srh/rethinkdb/releases/download/v2.3.6.srh.1/rethinkdb_2.3.6.srh.1.0bionic_amd64.deb
RUN dpkg -i rethinkdb_2.3.6.srh.1.0bionic_amd64.deb

ADD rethinkdb_tables /opt/rethinkdb_tables
RUN pip3 install rethinkdb==2.3

ADD entry_point.sh /opt/entry_point.sh

ENV RUN_ENV docker-compose

RUN id
RUN apt-get update &amp;&amp; apt-get install -y sudo
RUN groupadd newuser
RUN useradd -u 1000 -m -g newuser newuser
RUN adduser newuser sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' &gt;&gt; /etc/sudoers
RUN mkdir /data
RUN chown -R newuser:0 /opt/
RUN chown -R newuser:0 /data
USER newuser

ENTRYPOINT [ "sh", "/opt/entry_point.sh" ]
CMD []
</code></pre>

<p>The entry_point.sh is a small script that starts the rethinkdb and as soon as the rethinkdb is up it imports some tables. But I am getting below error:</p>

<pre class="lang-sh prettyprint-override"><code>Launch rethinkdb in Kubernetes
Could not create directory 'rethinkdb_data': Permission denied
</code></pre>

<p>How I can fix this? I have to mention that this is the way that I used to run my other images as non-root and this worked for them.</p>

AVarf
<p>Since the rethinkdb wanted to create the <code>rethinkdb_data</code> at <code>/</code> I decided to create that directory myself in the Dockerfile and change its owner so rethinkdb can access it and this solved my problem.</p>
