Skip to content

Commit 0b2839d

Browse files
committed
Fix psql command to pick up the latest docker host IP
1 parent a35e365 commit 0b2839d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

getting-started/running-gatewayd.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ docker run --rm --name postgres-test -p 5432:5432 -e POSTGRES_PASSWORD=postgres
3232
Test your database by running the following command:
3333

3434
```bash
35-
docker exec -it postgres-test psql postgresql://postgres:postgres@localhost:5432/postgres -c "\d"
35+
DOCKER_HOST=$(ip addr show docker0 | grep inet | grep -v inet6 | awk -F' ' '{ print $2 }' | sed 's/\/16//g')
36+
docker exec -it postgres-test psql postgresql://postgres:postgres@${DOCKER_HOST}:5432/postgres -c "\d"
3637
```
3738

3839
Since the database is just created, no relations exist.
@@ -116,10 +117,11 @@ Running GatewayD will produce the following log output, which means that Gateway
116117
117118
## 5. Test your setup with `psql`
118119

119-
GatewayD is running on the host, while PostgreSQL is running inside a container. You can run the following command to test it. Notice that `172.17.0.1` is the IP address of the host machine.
120+
GatewayD is running on the host, while PostgreSQL is running inside a container. You can run the following command to test it. Notice that `${DOCKER_HOST}` holds the IP address of the host machine, that is accessible from inside the container.
120121

121122
```bash
122-
docker exec -it postgres-test psql postgresql://postgres:postgres@172.17.0.1:15432/postgres
123+
DOCKER_HOST=$(ip addr show docker0 | grep inet | grep -v inet6 | awk -F' ' '{ print $2 }' | sed 's/\/16//g')
124+
docker exec -it postgres-test psql postgresql://postgres:postgres@${DOCKER_HOST}:15432/postgres
123125
```
124126

125127
Now you can create a table and insert data into it. Querying the data will trigger the cache plugin to store the results in Redis and subsequent SELECT queries will be served from the cache. The moment you insert a new value into the table or update a row, all the cached values from that table will be invalidated.

0 commit comments

Comments
 (0)