nautobot-docker-compose icon indicating copy to clipboard operation
nautobot-docker-compose copied to clipboard

Uploaded images do not persist across restarts

Open apanagio opened this issue 3 years ago • 5 comments

If you stop and restart nautobot instance, you cannot view the uploaded images

Way to reproduce

  • Start nautobot using docker-compose
  • Upload an image to a site
  • Restart nautobot
  • Notice the previously uploaded files are missing

Explanation

If I understand correctly this happens because the uploaded images are stored in the file system within the container and the filesystem is purged when the container stops

Proposed Fix

Mount a volume from the host system to store uploaded files

apanagio avatar Oct 01 '22 08:10 apanagio

@apanagio do you have a proposed standard of where to mount the volumes back to on the host? I feel like that may be something that we can add on via documentation unless we have a standard to adhere to?

jvanderaa avatar Oct 03 '22 14:10 jvanderaa

I don't have a proposal based on standards. I would suggest to do it as it is done with the "db_data" volume for the "db" service.

apanagio avatar Oct 03 '22 17:10 apanagio

I did set

    volumes:
    - nautobot-media-files:/opt/nautobot/media

in docker-compose.override.yml for the "main" nautobot service

EdificomSA avatar Oct 02 '23 08:10 EdificomSA

@EdificomSA how did you set up your permissions so that the nautobot user can write to that volume? I'm getting the following while trying to stand up Nautobot v1.6.2:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/nautobot/core/runner/runner.py", line 117, in settings_callback
    initializer(
  File "/usr/local/lib/python3.10/site-packages/nautobot/core/cli.py", line 123, in _configure_settings
    os.makedirs(os.path.join(settings.MEDIA_ROOT, "devicetype-images"))
  File "/usr/local/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/opt/nautobot/media/devicetype-images'

rlad78 avatar Oct 02 '23 12:10 rlad78

Yeah you might need to chown the folder in the named volume, look at : https://github.com/docker/compose/issues/3270#issuecomment-1245819741

EdificomSA avatar Oct 23 '23 11:10 EdificomSA

Closing as no longer relevant.

jdrew82 avatar Sep 10 '24 20:09 jdrew82