I'm trying to set security_opt according to official docker(docker-compose reference) docs. It doesnt seem to work from docker-compose.yaml. I've tried to google it but found weirdly limited amount of info about security_opt in docker.
I'm trying to start image with binary in docker-compose.yaml:
version: "3.7"
services:
test:
container_name: testcontainer
image: testimage
hostname: testhost
command: --test
volumes:
- ./data:/data
security_opt:
- label:user:testuser
- no-new-privileges:true
So when i run docker-compose up -d it starts this service from root, not from testuser.
But if i add user: uid:gid to the service config it starts from specified uid:
version: "3.7"
services:
test:
container_name: testcontainer
image: testimage
hostname: testhost
command: --test
volumes:
- ./data:/data
security_opt:
- label:user:testuser
- no-new-privileges:true
user: 1001:1001
- Why
security_optdoesn't work? - What is the difference between
security_opt: - label:user:testuseranduser: uid:gid? - How can i check
security_optsettings been applied?
It seems that not a lot of info about this topic on google. Thanks in advance.