I have a Docker container that needs to access files from Amazon S3 (cloud storage) using URLs.
The code is fine, tested, and works locally when not within a Docker container. However once running inside a container I keep getting the following error:
[tcp @ 0x60636c0] Failed to resolve hostname xxxddd999.s3.amazonaws.com: Name or service not known
That error is coming from a piece of code that needs to read in a file from a full AWS S3 location URL. But it fails because it can’t resolve the URL.
The command to make/run the container is:
docker run --restart unless-stopped -p 4545:4545 --name fileprocessor fileprocessor:stage
It creates the container fileprocessor:stage
from the image fileprocessor
and exposes port 4545
to run on. I have tried adding --net=host
flag to the command but that is useless and stops the port being exposed.
I am running this with nginx
(on Windows for now but will move it to a Ubuntu server for prod). I think I have to do something in the nginx.conf
file but can’t figure it out. Doing the following didn’t work:
location /xxxddd999.s3.amazonaws.com/ {
proxy_pass http://localhost;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}