I have a Dockerfile and custom nginx configuration file (in the same directory with Dockerfile) as follows:
Dockerfile:
FROM nginx
COPY nginx.conf /
As mentioned in the NGiNX documentation, upstream is supposed to be defined in an http context.
As mentioned in nginx unkown directive “upstream”:
When that file is included normally by
nginx.conf, it is included already inside thehttpcontext:
http {
include /etc/nginx/sites-enabled/*;
}
You either need to use
-c /etc/nginx/nginx.confor make a small wrapper like the above block andnginx -cit.
In case of Docker, you can see different options with abevoelker/docker-nginx:
docker run -v /tmp/foo:/foo abevoelker/nginx nginx -c /foo/nginx.conf
For a default nginx.conf, check your CMD:
CMD ["nginx", "-c", "/data/conf/nginx.conf"]