Home > other >  Docker Nginx proxy container connected? How does this configuration
Docker Nginx proxy container connected? How does this configuration

Time:10-22

Host 192.168.99.100 installation docker below, and have to deploy a good site in container
(container name netcore_helloworld, container IP 172.17.0.12 can 192.168.99.100:8066 access)


Create a helloworld Nginx configuration file. The conf


 

Server {
Listen, 801; # listening port 801

The location/{
Proxy_pass http://netcore_helloworld:80; # here forwarding IP is not used, use the container name: port
}
}




The custom Nginx mirror Dockerfile

 

# define base image nginx: latest
The FROM nginx
# copy custom configuration file to Nginx configuration file directory
COPY the helloworld. Conf/etc/nginx/conf. D/helloworld. Conf
# port 80 exposed to external
EXPOSE 80
# container operation parameters
CMD [nginx "-", "g", "the daemon off;"]




Making mirror for anginx


Docker run - name mynginx - d - 801 p: 80-80 801 - p anginx

After failing to look at the journal
Docker logs tip
Host not found in upstream "netcore_helloworld" in/etc/nginx/conf. D/helloworld. Conf: 4


Looking for a lot of data

The helloworld. Conf to modify the following code


 

Upstream webapi {

# server www.google.com weight=10;
# server www.badi.com weight=3;
Server netcore_helloworld: 80 weight=5;
Server 172.17.0.12:80 weight=5;

}

Server {
Listen, 801; # listening port 801

The location/{
Proxy_pass http://netcore_helloworld; # here forwarding IP is not used, use the container name: port
}
}




Container can be launched, but the custom Nginx mirror has not come agent

So what do I do right way?


========================================================

My goal is to have a custom in Docker Nginx mirror, and a separate configuration file helloworld. Conf.
The Nginx container can communicate with each other and other web container and the implementation agent

Is now a web container all access (the host IP and IP or container), how to access through the custom Nginx now?


If the helloworld. Write a death in the conf test IP or domain name is no problem, but now I want to use the container: port can be implemented?




CodePudding user response:




Can find many articles said container: port failed

CodePudding user response:



Been pit they say cannot access since the start and then docker network connect is ok, in fact is you must first network connect or more don't start the container

Finally you want to along while trying to succeed, those who don't network connect will be able to start the container I also don't know how to successful people
  • Related