Docker Community Forums

Share and learn in the Docker community.

AWS S3 links return 403 Forbidden in docker swarm but not in docker-compose

I have a dockerized 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)

The only changes I made were in the Compose file to set it up for Swarm. Code was left unchanged. So what does Docker Swarm do differently compared to docker-compose, that S3 is not able to authorize?

I can’t figure out what’s causing this. Any help will be appreciated!

Some additional info:

  • Docker Version: 20.10.7, build f0df350
  • Docker Compose: 1.29.2
  • Architecture: ARM64
  • OS: Ubuntu 20.04