Do we need to restart the Nginx in a docker container?

I’ve the following Dockerfile:

FROM nginx
ARG BuildMode
ENV BuildMode=${BuildMode}
RUN echo BuildMode
COPY ./dist/omg-portal-frontend /usr/share/nginx/html
COPY ./nginx/default.${BuildMode}conf /etc/nginx/conf.d/default.conf

So do I need to add the following command? (to restart the Nginx service)

RUN service nginx restart

When I do, I get the following error:

[emerg] host not found in upstream "ppd-omg-backend-service.azure.omgcom.net" in /etc/nginx/conf.d/default.conf:17

Line 17:

proxy_pass http://ppd-omg-backend-service.azure.omgcom.net/;

Can anyone help me with this?
When I remove the command, I get build success, but I’m not sure if the container is reflecting the latest config changes…

You generally do not need to restart the Nginx service manually within a Docker container. The Nginx service starts with the configuration provided at the time the container starts, so any changes made to the configuration files before the container starts will be applied automatically.

Your Dockerfile copies the configuration and HTML files correctly, so a manual restart isn’t necessary. However, ensure the BuildMode argument is set correctly and that the corresponding configuration file exists.

The error [emerg] host not found in upstream “ppd-omg-backend-service.azure.omgcom.net” in /etc/nginx/conf.d/default.conf:17 indicates a DNS resolution issue. This could be due to DNS settings or network configuration within the Docker container. Make sure your Docker environment can resolve external DNS names and that your network allows DNS resolution for external domains.

If the problem persists, consider checking your Docker daemon’s DNS configuration or adding a script to delay Nginx startup until the DNS name is resolvable. However, this is more of a workaround, and resolving the underlying DNS issue is preferable.

applies to docker swarm ?

What does apply to Docker swarm? The question or the most likely AI generated previous post? :slight_smile:

but no, you don’t restart anything inside a container usually, only the container itself which is the restart of the process inside the container.

And trying to restart nginx during an image build process doesn’t make sense at all, since nginx is not running and each RUN instruction starts a new temporary builder container where you have nothing except the command you specify after the RUN keyword.

Doesn’t matter what starts the final container eventually