nautobot-docker-compose
nautobot-docker-compose copied to clipboard
Uploaded images do not persist across restarts
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 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?
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.
I did set
volumes:
- nautobot-media-files:/opt/nautobot/media
in docker-compose.override.yml for the "main" nautobot service
@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'
Yeah you might need to chown the folder in the named volume, look at : https://github.com/docker/compose/issues/3270#issuecomment-1245819741
Closing as no longer relevant.