Incorrect URL on WordPress using Docker

I’ve a pretty simple setup using WordPress and Docker, with a docker-compose.yml file:

  wordpress:
    depends_on:
      db:
        condition: service_healthy
    restart: on-failure
    image: wordpress:latest
    volumes:
      - ./backend/wordpress/wp-content:/var/www/html/wp-content
      - ./backend/wordpress/.htaccess:/var/www/html/.htaccess
    environment:
      WORDPRESS_DB_HOST: ${WORDPRESS_DB_HOST}
      WORDPRESS_DB_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      WORDPRESS_TABLE_PREFIX: ${WORDPRESS_TABLE_PREFIX}
      WORDPRESS_CONFIG_EXTRA:
        define('WP_ALLOW_REPAIR', true );
        define('WP_HOME','${WORDPRESS_URL}:${NGINX_EXTERNAL_PORT}');
        define('WP_SITEURL','${WORDPRESS_URL}:${NGINX_EXTERNAL_PORT}');


  nginx:
    build: ./backend/nginx
    links:
      - wordpress
      - phpmyadmin
    ports: 
      - ${NGINX_EXTERNAL_PORT}:80
    volumes:
      - "./backend/nginx/nginx.conf:/etc/nginx/nginx.conf"

And this is my nginx.conf file:

upstream docker-wordpress {
    server wordpress;
}
server {
        listen 80;
        server_name admin.example.com;
        location / {
            proxy_read_timeout 3600;
            proxy_pass http://docker-wordpress;
        }
    }

Everything seems to work correctly till I try to sort my WordPress posts by name or slug or whatever field you want, and not only when I sort but also when I try to go to a 2nd page. Instead of getting something like:

http://admin.example.com:5000/wp-admin/edit.php?post_type=artista&orderby=title&order=asc

I get my upstream name on the links, like this:

http://docker-wordpress/wp-admin/edit.php?post_type=artista&orderby=title&order=asc

As I said, everything else works fine, and after taking a look at my site configuration I see that both WordPress URL and Site URL are:

http://admin.example.com:5000

Which I believe it’s correct, any idea what could be wrong? Thanks!

Source: StackOverflow