mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 15:18:01 +00:00
Add Check Postgres Version Running In Docker Container as a Docker TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1618 TILs and counting..._
|
||||
_1619 TILs and counting..._
|
||||
|
||||
See some of the other learning resources I work on:
|
||||
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
|
||||
@@ -224,6 +224,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
|
||||
### Docker
|
||||
|
||||
- [Check Postgres Version Running In Docker Container](docker/check-postgres-version-running-in-docker-container.md)
|
||||
- [Configure Different Host And Container Ports](docker/configure-different-host-and-container-ports.md)
|
||||
- [List Running Docker Containers](docker/list-running-docker-containers.md)
|
||||
- [Prevent Containers From Running On Startup](docker/prevent-containers-from-running-on-startup.md)
|
||||
|
||||
28
docker/check-postgres-version-running-in-docker-container.md
Normal file
28
docker/check-postgres-version-running-in-docker-container.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Check Postgres Version Running In Docker Container
|
||||
|
||||
I have a docker container that I'm using to run a PostgreSQL development
|
||||
database on my local machine. It was a while ago when I set it up, so I can't
|
||||
remember specifically which major version of PostgreSQL I am using.
|
||||
|
||||
I use `docker ps` to list the names of each container.
|
||||
|
||||
```bash
|
||||
$ docker ps --format "{{.Names}}"
|
||||
still-postgres-1
|
||||
better_reads-postgres-1
|
||||
```
|
||||
|
||||
I grab the one I am interested in. In this case, that is `still-postgres-1`.
|
||||
|
||||
Then I can execute a `select version()` statement with `psql` against the
|
||||
container with that name like so:
|
||||
|
||||
```bash
|
||||
$ docker exec still-postgres-1 psql -U postgres -c "select version()";
|
||||
version
|
||||
---------------------------------------------------------------------------------------------------------------------
|
||||
PostgreSQL 16.2 (Debian 16.2-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
|
||||
(1 row)
|
||||
```
|
||||
|
||||
And there I have it. I'm running Postgres v16 in this container.
|
||||
Reference in New Issue
Block a user