Hi All,
I want to spwan an nginx from docker , via Docker file I am using CMD nginx followed by other configuration in Dockerfile and then run the docker in daemon mode, the container is up but nginx is not started…kindly help what i am missing!!
As stated in my comment, a strong possibility is a syntax error in the nginx config files on the host.
If you copy the default nginx config file to the host, the commands above run fine, but if you introduce a syntax error into the config file on the host, then the container will not run.
I’m wondering how to know what you are missing when you have shown very little what you are not missing. What have you discovered about the base docker image, or in the system logs, or in ngnix stderr/stdout? You can exec into the container and look around inside to make sure config is what you want. Some base images use ‘entrypoint’, does yours?
docker run -t -d -p 8085:80 --name myname new /usr/sbin/nginx -g "daemon off…Solved my problem!!!
It’s also important to understand why that fixed your problem. The Docker container will exit when the main process terminates. Unfortunately, any process that runs as a daemon looks like it has terminated so the container exits. By using "deamon off"
you have instructed nginx to run in the foreground so that the container stays alive.
Always run the main process in the foreground when using containers.
As stated in my comment, a strong possibility is a syntax error in the nginx config files on the host.
If you copy the default nginx config file to the host, the commands above run fine, but if you introduce a syntax error into the config file on the host, then the container will not run.
Hi there, it sounds like you’re having trouble getting Nginx to start inside your Docker container.
One thing to check is whether there are any errors in your Docker logs that might provide a clue as to what’s going wrong. You can use the docker logs
command to view the logs for your container.
Another thing to check is whether the Nginx process is actually running inside the container. You can use the docker exec
command to run a shell inside the container and check whether the Nginx process is running using ps -ef
.
If the Nginx process is not running, it’s possible that there is an issue with your Dockerfile or configuration. Some potential issues to check include:
- Is Nginx installed correctly in your Docker image?
- Are there any errors in your Nginx configuration that might be preventing it from starting?
- Is there a conflict with the port that Nginx is configured to listen on?
Without more information about your specific setup, it’s difficult to provide more specific advice. I would recommend checking the Docker logs and running a shell inside the container to see if you can identify any issues. Good luck!