Contact Form

Name

Email *

Message *

Cari Blog Ini

Docker Compose Changing Postgres And Pgadmin Container Ports

Docker Compose: Changing Postgres and PgAdmin Container Ports

Modifying Postgres Server Port

In a Docker Compose environment, you can specify the port that the Postgres server listens on by utilizing the ports parameter. For example:

``` ports: - "5432:5432" ```

This configuration maps port 5432 on the host machine to port 5432 within the Postgres container, allowing you to access the database using the host's port.

Adjusting PgAdmin Web Interface Port

Similarly, you can modify the port for the PgAdmin web interface. By default, PgAdmin listens on port 80, but you can change this to a different port, such as 8080:

``` ports: - "8080:80" ```

This configuration maps port 8080 on the host machine to port 80 inside the PgAdmin container, allowing you to access the web interface using the host's 8080 port.

Conclusion

Using Docker Compose, you can effortlessly customize the ports for both Postgres and PgAdmin containers. This provides flexibility in configuring your Docker environment and allows you to easily access your database and web interface through convenient host ports.


Comments