instruction: Create a comprehensive Dockerfile for networking applications with best practices
output: ```dockerfile
  from
  the name that the ExternalName references.
  For protocols that use hostnames this difference may lead to errors or unexpected responses.
  HTTP requests will have a Host: header that the origin server does not recognize;
  TLS servers will not be able to provide a certificate matching the hostname that the client connected to.
  
  Headless Services
  Sometimes you don't need load-balancing and a single Service IP. In
  this case, you can create what are termed headless Services, by explicitly
  specifying "None" for the cluster IP address (.spec.clusterIP).
  You can use a headless Service to interface with other service discovery mechanisms,
  without being tied to Kubernetes' implementation.
  For headless Services, a cluster IP is not allocated, kube-proxy does not handle
  these Services, and there is no load balancing or proxying done by the platform for them.
  A headless Service allows a client to connect to whichever Pod it prefers, directly. Services that are headless don't
  configure routes and packet forwarding using
  virtual IP addresses and proxies; instead, headless Services report the
  endpoint IP addresses of the individual pods via internal DNS records, served through the cluster's
  DNS service.
  To define a headless Service, you make a Service with .spec.type set to ClusterIP (which is also the default for type),
  and you additionally set .spec.clusterIP to None.
  The string value None is a special case and is not the same as leaving the .spec.clusterIP field unset.
  How DNS is automatically configured depends on whether the Service has selectors defined:
  With selectors
  For headless Services that define selectors, the endpoints controller creates
  EndpointSlices in the Kubernetes API, and modifies the DNS configuration to return
  A or AAAA records (IPv4 or IPv6 addresses) that point directly to the Pods backing the Service.
  Without selectors
  For headless Services that do not define selectors, the control plane does
  not create EndpointSlice objects. However, the DNS system looks for and configures
  either:
  
  DNS CNAME records for type: ExternalName Services.
  DNS A / AAAA records for all IP addresses of the Service's ready endpoints,
  for all Service types other than ExternalName.
  
  For IPv4 endpoints, the DNS system creates A records.
  For IPv6 endpoints, the DNS system creates AAAA records.
  
  When you define a headless Service without a selector, the port must
  match the targetPort.
  Discovering services
  For clients running inside your cluster, Kubernetes supports two primary modes of
  finding a Service: environment variables and DNS.
  Environment variables
  When a Pod is run on a Node, the kubelet adds a set of environment variables
  for each active Service. It adds {SVCNAME}_SERVICE_HOST and {SVCNAME}_SERVICE_PORT variables,
  where the Service name is upper-cased and dashes are converted to underscores.
  For example, the Service redis-primary which exposes TCP port 6379 and has been
  allocated cluster IP address 10.0.0.11, produces the following environment
  variables:
  REDIS_PRIMARY_SERVICE_HOST=10.0.0.11
  REDIS_PRIMARY_SERVICE_PORT=6379
  REDIS_PRIMARY_PORT=tcp://10.0.0.11:6379
  REDIS_PRIMARY_PORT_6379_TCP=tcp://10.0.0.11:6379
  REDIS_PRIMARY_PORT_6379_TCP_PROTO=tcp
  REDIS_PRIMARY_PORT_6379_TCP_PORT=6379
  REDIS_PRIMARY_PORT_6379_TCP_ADDR=10.0.0.11
  
  Note:When you have a Pod that needs to access a Service, and you are using
  the environment variable method to publish the port and cluster IP to the client
  Pods, you must create the Service before the client Pods come into existence.
  Otherwise, those client Pods won't have their environment variables populated.
  If you only use DNS to discover the cluster IP for a Service, you don't need to
  worry about this ordering issue.
  
  Kubernetes also supports and provides variables that are compatible with Docker
  Engine's "legacy container links" feature.
  You can read makeLinkVariables
  to see how this is implemented in Kubernetes.
  DNS
  You can (and almost always should) set up a DNS service for your Kubernetes
  cluster using an add-on.
  A cluster-aware DNS server, such as CoreDNS, watches the Kubernetes API for new
  Services and creates a set of DNS records for each one. If DNS has been enabled
  throughout your cluster then all Pods should automatically be able to resolve
  Services by their DNS name.
  For example, if you have a Service called my-service in a Kubernetes
  namespace my-ns, the control plane and the DNS Service acting together
  create a DNS record for my-service.my-ns. Pods in the my-ns namespace
  should be able to find the service by doing a name lookup for my-service
  (my-service.my-ns would also work).
  Pods in other namespaces must qualify the name as my-service.my-ns. These names
  will resolve to the cluster IP assigned for the Service.
  Kubernetes also supports DNS SRV (Service) records for named ports. If the
  my-service.my-ns Service has a port named http with the protocol set to
  TCP, you can do a DNS SRV query for _http._tcp.my-service.my-ns to discover
  the port number for http, as well as the IP address.
  The Kubernetes DNS server is the only way to access ExternalName Services.
  You can find more information about ExternalName resolution in
  DNS for Services and Pods.
  
  Virtual IP addressing mechanism
  Read Virtual IPs and Service Proxies explains the
  mechanism Kubernetes provides to expose a Service with a virtual IP address.
  Traffic policies
  You can set the .spec.internalTrafficPolicy and .spec.externalTrafficPolicy fields
  to control how Kubernetes routes traffic to healthy (“ready”) backends.
  See Traffic Policies for more details.
  Traffic distribution
  
  FEATURE STATE: Kubernetes v1.30 [alpha]
  
  The .spec.trafficDistribution field provides another way to influence traffic
  routing within a Kubernetes Service. While traffic policies focus on strict
  semantic guarantees, traffic distribution allows you to express preferences
  (such as routing to topologically closer endpoints). This can help optimize for
  performance, cost, or reliability. This optional field can be used if you have
  enabled the ServiceTrafficDistribution feature
  gate for your
  cluster and all of its nodes. In Kubernetes 1.30, the
  following field value is supported:
  
  PreferClose
  Indicates a preference for routing traffic to endpoints that are topologically
  proximate to the client. The interpretation of "topologically proximate" may
  vary across implementations and could encompass endpoints within the same
  node, rack, zone, or even region. Setting this value gives implementations
  permission to make different tradeoffs, e.g. optimizing for proximity rather
  than equal distribution of load. Users should not set this value if such
  tradeoffs are not acceptable.
  
  If the field is not set, the implementation will apply its default routing strategy.
  See Traffic
  Distribution for
  more details
  Session stickiness
  If you want to make sure that connections
  ```