Skip to content

How to change port 8080 to some other port #893

@WilberRojas

Description

@WilberRojas

Hi, I'm running the following docker-compose. My goal is to change the exposed port of the service from 8080 to another value, for example, 8081. However, when I make this change and access it through http://localhost:8081/, I'm automatically redirected to http://localhost:8080/. It seems there's some internal configuration or redirection that is forcing the use of port 8080. How can I troubleshoot this issue and ensure that my application runs correctly on the new port?

  • .env file
DB_NAME=wordpress1
DB_USER=admin
DB_PASSWORD=admin
DB_ROOT=admin
PORT=8081
  • docker compose file
version: '3.1'

services:
  db:
    image: mysql
    container_name: ${DB_NAME}_db
    restart: always
    environment:
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DB_USER}
      MYSQL_PASSWORD: ${DB_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${DB_ROOT}
    volumes:
      - db:/var/lib/mysql

  wordpress:
    depends_on:
      - db
    image: wordpress
    container_name: ${DB_NAME}_wordpress
    restart: always
    ports:
      - ${PORT}:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: ${DB_USER}
      WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
      WORDPRESS_DB_NAME: ${DB_NAME}
    volumes:
      - wordpress:/var/www/html

volumes:
  wordpress:
  db:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions