'why i can not change nginx container and target port in k8s

I have below manifest file to deploy nginx pod in k8s with container port and target port 80. When I set these ports other than 80 say eg 8080, I am not able to access the nginx pod from outside using curl cmd with nodeip and node port. Why the nginx docker image does not accept other ports? I checked nginx image doc in docker hub but did not get any such restriction.

/home/ravi/k8s>cat nginx.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx-app
  template:
    metadata:
      labels:
        app: nginx-app
    spec:
      containers:
      - name: nginx-container
        image: nginx:1.16
        ports:
        - containerPort: 80
---        
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  type: NodePort
  selector:
    app: nginx-app
  ports:
    - protocol: TCP           
      nodePort: 31000
      port: 80
      targetPort: 80       
/home/ravi/k8s>


/home/ravi>curl  192.168.49.2:31000   --> change port in yaml other than 80, then this will not work
<!DOCTYPE html>
<html>
<head>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source