S3 Provider gives 502 status code in production in dockerized Strapi

I have created a custom s3 provider for media upload. The uploads work perfectly in development. But in production, the upload fails with 502 bad request. It shows a file size is too large error in the logs (tried with 98kb image also). We have a read only file-system with docker in production. For uploads to work, which folders require read and write permissions in a system?