I have a Django application and related services running on an EC2 ubuntu instance. The static files are being stored and fetched from S3 using django-storages library and are working fine when I start the services using docker-compose. But recently I tried to set it up on 2 different EC2 servers running under same security group using Docker Swarm, and none of the S3 static file links are working. All of them throw this error in browser console:
Failed to load resource: the server responded with a status of 403 (Forbidden)
Also, when I use
collectstatic to copy the files over to S3, it shows "4066 static files copied", but there’s nothing on S3 bucket. The same however, when run on docker-compose copies all the files correctly, and if nothing was changed, shows "0 static files copied"
The only changes I made were in the Compose file (to set it up for swarm) and opening required ports on EC2 security groups. Code was left untouched.
I can’t figure out what’s causing this exactly. Any help will be appreciated!
Source: Docker Questions