My app runs at the following location on the container
/home/unity/.config/unity3d/Lee/MyApp
Inside my app I can read/write files to that location just fine, but they’re not persisted, so I’m trying to create a volume that my app can reach to save/open files that stick around between instances.
I tried adding that path to a volume
docker-compose segment:
volumes:
- '/game-data:/data
- ‘/persistant:/home/unity/.config/unity3d/Lee/MyApp’
But when I try to save a file to /home/unity/.config/unity3d/Lee/MyApp I get:
UnauthorizedAccessException: Access to the path “/home/unity/.config/unity3d/Lee/MyApp/data.json” is denied.
If I remove the line with /persistent/ from my compose, and run the app:
Debug.Log(“/data exists? " + Directory.Exists(”/data")); //true
Debug.Log(Path.GetFullPath(“/data”)); //only shows /data
If I try to save my file to /data or ./data (which should be a volume defined in compose above?), it fails with an exception:
Could not find a part of the path “/data/data.json”
I can write data.json to /home/unity/mydir and read from it but if I try to make home/unity/mydir a volume i can no longer read/writeto it.
By default my code in my app saving to its local folder is here:
/home/unity/.config/unity3d/Lee/MyApp/
If I try to access a different folder like /data in code I get a access denied exception. I honestly don’t care where the files are stored I just want to be able to persist wherever I’m saving to, and each time the app opens, have access to that location. (From within my app running in the container)
This is my Dockerfile I pieced together, its probably terrible but works
FROM ubuntu:latest
RUN apt-get update -qq;
apt-get install -qq -y
zip
&& apt-get clean
&& rm -rf /var/lib/apt/lists/*
COPY headless.zip .
RUN unzip headless.zip
RUN useradd -ms /bin/bash unity
RUN chown unity:unity -R headless_server.x86_64
USER unity
RUN [“chmod”, “+x”, “/headless_server.x86_64”]
ENTRYPOINT [“/headless_server.x86_64”]
Can anyone explain what I need to do to either mount my directory where my app is as a volume I can access, or how to access the volume from my code if somewhere else, both ways I’ve tried are throwing exceptions.