The two containers share a network namespace, so each application needs to listen on a different port, they can't both bind to port 80.
On Thu, Mar 2, 2017 at 6:36 PM, Montassar Dridi <montassar0dr...@gmail.com> wrote: > I'm trying to create two containers (tomact image) inside my web pod: > each one going to run a java application but I want them to share the same > ip address > > apiVersion: extensions/v1beta1 > kind: Deployment > metadata: > name: web-dp > labels: > name: web-pod > version: v1 > spec: > template: > metadata: > labels: > name: web-pod > version: v1 > spec: > containers: > - image: gcr.io/projectid/webapp:1 > name: web-pod > ports: > - containerPort: 8080 > - image: gcr.io/projectid/webapp:2 > name: crm-pod > ports: > - containerPort: 8081 > ------------- > apiVersion: v1 > kind: Service > metadata: > name: web-service > labels: > name: web-pod > version: v1 > spec: > type: NodePort > ports: > - port: 80 > targetPort: 8080 > protocol: TCP > name: app1 > nodePort: 30531 > - port: 80 > targetPort: 8081 > protocol: TCP > name: app2 > nodePort: 31352 > selector: > name: web-pod > > I'm using an NGINX-ingress-controller+Ingress for the service > > apiVersion: extensions/v1beta1 > kind: Ingress > metadata: > name: amenity-smartlab-ing > annotations: > kubernetes.io/ingress.class: "nginx" > spec: > rules: > - http: > paths: > - backend: > > serviceName: web-service > servicePort: 80 > path: / > > I get this error in my logs > java.lang.Exception: Socket bind failed: [98] *Address* already in use > <https://www.google.ca/search?q=java.lang.Exception%3A+Socket+bind+failed%3A+%5B98%5D+Address+already+in+use&oq=java.lang.Exception%3A+Socket+bind+failed%3A+%5B98%5D+Address+already+in+use&aqs=chrome..69i57j69i60&sourceid=chrome&ie=UTF-8#q=kubernetes+Socket+bind+failed:+%5B98%5D+Address+already+in+use&*> > > -- > You received this message because you are subscribed to the Google Groups > "Kubernetes user discussion and Q&A" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to kubernetes-users+unsubscr...@googlegroups.com. > To post to this group, send email to kubernetes-users@googlegroups.com. > Visit this group at https://groups.google.com/group/kubernetes-users. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group. To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscr...@googlegroups.com. To post to this group, send email to kubernetes-users@googlegroups.com. Visit this group at https://groups.google.com/group/kubernetes-users. For more options, visit https://groups.google.com/d/optout.