title: How to give docker container write/chmod permissions on mapped volume?
body: <p>I have a synology NAS which has docker support and wanted to run some docker containers (I'm pretty new to Docker) on it. For example pocketmine-pm (but I believe I have the write issue also with other containers).</p>
  
  <p>I created a volume on the host and mapped this in the container settings. (And in the synology docker settings for the volume mapping I did not click on "read only").</p>
  
  <p>According to the Dockerfile a new user 'pocketmine' is created inside the container and this user is used to start the server. The user seems to have the user ID 1000 (first UID for new linux users). The container also uses an Entrypoint.sh script to start the server.</p>
  
  <p>Initially the container was not able to write files to the mapped directory. I had to SSH into the host 'chown' the directory for the UID 1000:</p>
  
  <pre><code>sudo chown 1000:1000 /volXy/docker/pocketminemp -R
  </code></pre>
  
  <p>After that the archive could be downloaded and extracted.</p>
  
  <p>Unfortunately I was not able to connect to the server from my iOS device. The server is listed as 'online' but the connection fails without any specific message. I then checked the logs of the container and saw the following entries (not sure if this really prevents the connection but I will give it a try):</p>
  
  <pre><code>[*] Everything done! Run ./start.sh to start PocketMine-MP
  chown: changing ownership of '/pocketmine/entrypoint.sh': Operation not permitted
  chown: changing ownership of '/pocketmine/server.properties.original': Operation not permitted
  Loading pocketmine.yml...
  </code></pre>
  
  <p>Apparently the container cannot chown a file it was previously able to download.</p>
  
  <p>Does anybody know what can be done to fix this? Do I need to <code>chmod</code> the mapped volume and why did I need to <code>chown</code> the directory to UID 1000 (a user that doesn't really exist on the host) - isn't there a more elegant way to fix the permissions?</p>