I'm trying to pull nginx from docker hub using python docker library. After pulling the nginx i want to run it and configure it to test some RestAPI requests - only basic ones to get response (200 OK).
What i already have is the following:
img = client.images.pull('nginx:latest')
client.containers.run(img, detach=True)
After these lines i can see the new docker in the list got here:
client.containers.list()
currently there is nothing happened, got nothing in http://localhost:8080. what do i missed? how to configure this nginx in the docker with the python library?
Update and more info:
The solution of the port was very helpful.
Now i can send GET request and get a response with "200 OK"
But now when i'm trying to send POST request i got "405 Not Allowed".
In a quick search in google i found that i need to configure nginx.config
in this way:
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 404 /404.html;
error_page 403 /403.html;
# To allow POST on static pages
error_page 405 =200 $uri;
# ...
}
My question now is how can i config this file with the docker API? Is this the right solution? replace 405 with 200??
Thanks.