Nginx container creation

I have the nginx vanilla image pulled from Docker Hub, and when I use the following command (found in several online tutorials)-
docker run --name mynginx2 -v /var/www:/usr/share/nginx/html:ro
-v /var/nginx/conf:/etc/nginx:ro -P -d nginx
It creates a container that quits immediately, and does not construct the ports according to -P that should be there. I can’t check the container config files because I can’t get the container to start.
My feeling is that because the -v options in the above command do their work, they create a “bad” container, something without a config file or something of that nature. I am a noob to Docker and nginx, so I’m not sure. I would like to follow the additional tutorials that set up the nginx container from a Dockerfile, I suppose I’ll try that next.
When I run a command like-
docker run --name myginx1 -P -d nginx
a good container is created, lives, and I can view its default web page in a browser from anywhere on my network if I specify an IP of say 196.168.0.6:3xxxx, where 3xxxx is the port exposed on the host by the -P option.
I would appreciate any suggestions about what could be wrong with the first command above.
Thanks!
Sincerely,
Robert M. Koretsky

Hi,

Can you check the logs that was generated from the mynginx1 container. It can give you the reason for why the container exited.

docker logs mynginx

Regards

Ranjandas:
Much thanks for your helpful and considerate reply, I solved this problem by looking at the instructions for basic use posted in DockerHub with the nginx image found there. If you put content, such as an actual .html file in /var/www, then the container is created successfully, and you can access it at the host port assigned. I did not try putting a new config file in /var/nginx/conf. When I learn more about the structure of a custom config file, I will try that too.
Sincerely,
Robert M. Koretsky