DEV Community

Aashutosh Poudel
Aashutosh Poudel

Posted on

Docker tips: Find IP of postgres database & View logs from a running container

1. Find IP of a PostgreSQL database running as a docker container

Run docker inspect <name-of-container>.

"NetworkSettings": {
            ...
            "Networks": {
                "name_of_your_database": {
                    ...,
                    "IPAddress": "172.18.0.2",
                    ...
                },
                ...
            }
        }
    }
Enter fullscreen mode Exit fullscreen mode

Next you can use the IPAddress from above to connect to your database using pgadmin.

Reference

2. View logs from a running docker container

In order to tail logs from inside a docker container.

Run docker logs --follow <name-of-your-container>

Reference

Top comments (0)