Docker creates files/folders as root although run with user option

Zoker

Member
Oct 31, 2020
36
10
13
I run a proxmox server and inside use a lot of little LXC containers running alpine with docker installed.

Bash:
apk add docker
apk add docker-compose
rc-update add docker boot

Until now I ran all these as root users (within the LXC container).
But to improve security, I created a separate docker user, added this user to the docker group and fixed the socket permissions:

Bash:
addgroup -g 1000 docker
adduser -u 1000 -G docker docker
chmod 666 /var/run/docker.sock

Here is the output of id docker:
xtBEf.png


After this I created a docker-compose.yml file and added the following content:

YAML:
version: '3.8'
  services:
    npm:
    image: jlesage/nginx-proxy-manager
    container_name: NPM
    restart: always
    user: 1000:1000
    ports:
      - 80:8080/tcp
      - 81:8181/tcp
      - 443:4443/tcp
    volumes:
      - ~/files/npm:/config

And finally I ran the docker-compose up command.

But the container always gets a permission denied error, when it tries to access the mounted volumes (which it create itself, but apparently as root user):
3Jy8a.png


Why are the files created as root user and why does the container not have any permissions to the folders? The user: 1000:1000 option in the compose file should do the trick, right?

When I run the docker as a command instead of the compose file, I have the same issue
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!