xetus-oss / docker-archiva

A docker image for Apache Archiva
Apache License 2.0
55 stars 34 forks source link

can't create directory '/archiva-data/data': Permission denied #29

Closed Artmorse closed 3 years ago

Artmorse commented 3 years ago

Using the command :

docker run --name archiva -v /volume1/docker/archiva/data:/archiva-data -p 62547:8080 xetusoss/archiva:v2

Results in:

WARNING: SMTP_HOST not set, Archiva cannot send emails!
WARNING: JVM_MAX_MEM has been depreciated and is no longer used!
Creating empty directory for data...
mkdir: can't create directory '/archiva-data/data': Permission denied

I see there is an old issue about the permissions : https://github.com/xetus-oss/docker-archiva/issues/3

tkent commented 3 years ago

👋 Hello!

Can you check that the directory you're mounting (/volume1/docker/archiva/data) allows the archiva process's user/group to access it.

How you do that is dependent on the OS and docker version you're using. For most setups, it's just making sure that UID 1000 / GID 1000 has read/write access to the directory.

Artmorse commented 3 years ago

It's OK !

I've added 2 environment variables (UID and GID) and it works.

docker run --name archiva -v /volume1/docker/archiva/data:/archiva/data -e UID=1026 -e GID=100 -p 62547:8080 xetusoss/archiva
Artmorse commented 3 years ago

Finally it doesn't work. My user have create the directory :

$ls -ltrah data
drwxrwxrwx+ 1 me users   0 Dec 14 10:45 data
$id me
uid=1026(me) gid=100(users) groups=100(users),101(administrators)

So, yesterday, I've added the variables :

But I can't create my directory ... (Permission denied)

When I do :

$chmod 777 data/

Now, my container have the good right to create files but 777 it's bad...

tkent commented 3 years ago

It seems you're bumping into confusion around file system permissions with local volume mounts. It's an easy thing to get tripped up by and has been discussed a lot (here and here, for example).

A few hints to sort it out

(1) Do not overwrite the process UID/GID

I would not recommend overwriting the UID/GID the archiva process runs as. That's something we've never tested.

(2) Create a local directory with the correct ownership/permissions

Follow the earlier suggestion of making sure the archiva process has read/write access to the local directory

mkdir my-archiva-data
chown 1000:1000 my-archiva-data
docker run -v "${PWD}/my-archiva-data:archiva-data" --name archiva -p 8080:8080 xetusoss/archiva

(3) Just use a data volume

If you're still struggling to get permissions sorted, just use a data volume on the host using commands like this...

# Creates a named volume that will not be removed when the container is removed.
docker volume create --name archiva-data

# Creates an archiva instance that uses the newly created data container
docker run -v archiva-data:/archiva-data --name archiva -p 8080:8080 xetusoss/archiva

or you can use the docker-compose sample in the readme, that works too.

Artmorse commented 3 years ago

Oh okay! Thanks a lot! :+1:

haydonryan commented 3 years ago

@Artmorse - Hi - Not sure if you're still experiencing this issue but I just ran into the same problem myself. First up, based on the path, I'm assuming you're using a Synology NAS. (Me too!)

The reason you're getting this is the docker container needs the permissions (at the Synology level) on the directory of the NAS. For example, In File Station, I set the directory permissions to give the system read/write access and it worked.

Right Click on the directory -> properties -> permissions tab -> add System as read / write.

I tried to lock it down further to a 1000 user, however that did not work.