title: A PostgreSQL 12 docker container failing to restart on a particular architecture
body: <p>The problem is very simple and easily reproduced if you have a Raspberry Pi.  I am attempting to restore a postgresql 12 database running inside a docker container from a base backup, but the problem stopping this happening is simply that with PG 12 and armv71 I can't restart the container having deleted the data directory, as explained below.</p>
  
  <p>I am using the official <a href="https://hub.docker.com/_/postgres" rel="nofollow noreferrer">postgresql docker container</a> via DockerHub on two different environments, one is my local dev environment which is a PC running Ubuntu 18 LTS, the other is a Raspberry Pi armv71.  </p>
  
  <p>The operation that I require is to delete the content of <code>/var/lib/postgresql/data</code> on the running container, and then restart the container, this according to the documentation will force the docker-entrypoint.sh script to run, allowing my restore scripts to fire (which it does on my Ubuntu machine).</p>
  
  <p>So on my PC this process works fine:</p>
  
  <pre><code>docker run --name website_db_1
  </code></pre>
  
  <p>This simply launches the default/vanilla postgresql docker container (I've left out the password on purpose)</p>
  
  <p>Then, once up and running, to force the container to run the docker-entrypoint.sh script I do:</p>
  
  <pre><code>docker exec -it website_db_1 bash -c "rm /var/lib/postgresql/data/* -r"
  docker container restart website_db_1
  </code></pre>
  
  <p>The container should re-initialise, and as I side point, if I were to add my appropriate restore script to the docker-entrpoint.sh file or init folder, I do get the wal archive restore to work correctly (on my Ubuntu PC).</p>
  
  <p>On the armv71 architecture however on my Raspberry Pi, this exact same code results in the following error in the container logs:</p>
  
  <pre><code>initdb: error: directory "/var/lib/postgresql/data" exists but is not empty
  db_1                           | If you want to create a new database system, either remove or empty
  db_1                           | the directory "/var/lib/postgresql/data" or run initdb
  db_1                           | with an argument other than "/var/lib/postgresql/data".
  </code></pre>
  
  <p>It is saying that the directory is not empty, but it should be as I just deleted it with the previous line, and the code works fine on Ubuntu.  Also on the Pi, I have watched from within the container to confirm that the directory does go empty as it should before restart.  What is going on?</p>
  
  <p>Another interesting fact, this process above works fine on both architectures using <code>postgres 11</code>, I am only having difficulty since updating to <code>postgres 12</code>.</p>
  
  <p>Any idea why PG 12 is causing this issue with armv71?  This is easily reproducible if you have a pi.</p>
  
  <p>In case its important, the following are the postgresql versions I am using:</p>
  
  <pre><code>PostgreSQL 12.1 (Debian 12.1-1.pgdg100+1) on arm-unknown-linux-gnueabihf, compiled by gcc (Debian 8.3.0-6)
  PostgreSQL 12.1 (Debian 12.1-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
  </code></pre>