vmware-archive / vsphere-storage-for-docker

vSphere Storage for Docker
https://vmware.github.io/vsphere-storage-for-docker
Apache License 2.0
251 stars 95 forks source link

Volume permission required to be set seperately from docker-compose file #2089

Open jetersen opened 5 years ago

jetersen commented 5 years ago

Initial volume does not give proper permission when used from docker-compose.

I have to manually create the volume and run chown on it.

docker volume create --name=jenkinsmaster_jenkins-home --driver=vsphere -o size=20gb
docker run --rm -v jenkinsmaster_jenkins-home:/var/jenkins_home alpine chown -R 1000:1000 /var/jenkins_home

Docker-compose file

version: '3.6'

services:
  jenkins:
    restart: always
    build: .
    ports:
      - 8080:8080
      - 50000:50000
    volumes:
      - jenkins-home:/var/jenkins_home

volumes:
  jenkins-home:
    driver: vsphere:latest
    driver_opts:
      size: 20gb

Dockerfile

FROM jenkins/jenkins:lts-alpine

....
freddyli commented 5 years ago

We have a similar problem, also wtih the jenkins image. One solution would be to provide docker with an empty volume. Currently when a VMDK is created and formatted, there is the lost+found directory inside. Therefore docker does not copy the directory from the image to the volume.

Now, if the volume was empty, and /var/jenkins_home inside the image has the correct owner (1000:1000), this ownership would be transferred onto the volume by docker.

So one solution would be to "mask" the lost+found directory e.g. by using a sub-directory on the volume filesystem as volume-root. See also:

https://github.com/vmware/vsphere-storage-for-docker/issues/2085 https://github.com/vmware/vic/issues/5777