<p><strong>Issue</strong></p>
<p>I've a set of working WordPress Docker Compose containers that includes blog image and db image.</p>
<pre><code>version: '3'
services:

  wordpress-app-db:
    build:
      context: ./mysql      
    image: wordpress-app-db:5.7-mysql
    restart: always

  php7-wordpress-app:
    depends_on:
      - wordpress-app-db
    build:
      context: ./wordpress    
    image: wordpress-app:php7    
    links:
      - wordpress-app-db
    ports:
      - &quot;8080:80&quot;
    restart: always

volumes:
  data:
</code></pre>
<p>Now, here the above <code>yaml</code> will work with no issues at all, but when I want to change the port <code>8080</code> to some other port it simply wont work.</p>
<pre><code>ports:
  - &quot;&lt;my-custom-port&gt;:80&quot;
</code></pre>
<p>All around the url takes me to <code>http://localhost:8080/</code>.</p>
<p>I'm confused of it's behaviour, I'm not able to understand why it is redirecting to <code>8080</code> if it has been mapped to other port <code>&lt;my-custom-port&gt;</code>.</p>
<p>For info, I've exposed port <code>80</code> in Dockerfile.</p>
<p><strong>Reason</strong></p>
<p>I want to do so, as I've to run this set in kubernetes cluster with <code>nodePort</code> and I can't assign it the port <code>8080</code> in <code>nodePort</code>.</p>

<p>Verify that the <code>siteurl</code> and <code>home</code> wp_options in your database are set to the correct hostname and port. I recently migrated a WordPress site from a LAMP compute instance to Kubernetes using the official WordPress images, and I experienced the exact same issue.</p>
<p>WordPress will perform a redirect if those values do not match your domain name.</p>
<p>In my case, the two fields mutated somehow during the migration, causing every request to redirect to <code>:8080</code>. They were changed to <code>localhost:8080</code>.</p>
