Skip to content

Instantly share code, notes, and snippets.

@onjin
Created August 17, 2016 06:33
Show Gist options
  • Save onjin/a6002f322776c7f59d5cbabc61b3063f to your computer and use it in GitHub Desktop.
Save onjin/a6002f322776c7f59d5cbabc61b3063f to your computer and use it in GitHub Desktop.
onjin postgresql docker compose
postgresql92:
image: onjin/alpine-postgres:9.2
volumes:
- $HOME/.volumes/postgresql92:/var/lib/postgresql/data
postgresql93:
image: onjin/alpine-postgres:9.3
volumes:
- $HOME/.volumes/postgresql93:/var/lib/postgresql/data
postgresql94:
image: onjin/alpine-postgres:9.4
volumes:
- $HOME/.volumes/postgresql94:/var/lib/postgresql/data
postgresql95:
image: onjin/alpine-postgres:9.5
volumes:
- $HOME/.volumes/postgresql95:/var/lib/postgresql/data
@onjin
Copy link
Author

onjin commented Aug 17, 2016

$ mkdir -p ~/.volumes/                           # create .volumes directory
$ docker-compose up -d                        # start all containers
$ docker-compose stop                          # stop all containers
$ docker-compose up -d postgresql93   # start postgres93
$ docker-compose ps                             # list containers

 $ docker-compose ps
        Name                      Command               State     Ports   
-------------------------------------------------------------------------
onjin_postgresql92_1   /docker-entrypoint.sh postgres   Exit 0            
onjin_postgresql93_1   /docker-entrypoint.sh postgres   Up       5432/tcp 
onjin_postgresql94_1   /docker-entrypoint.sh postgres   Exit 0            
onjin_postgresql95_1   /docker-entrypoint.sh postgres   Exit 0

$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' onjin_postgresql93_1
172.17.0.4

$ psql -U postgres -h 172.17.0.4

@onjin
Copy link
Author

onjin commented Aug 17, 2016

run different psql versions

onjin@nazano:~ (py-2.7.6)
 $ docker run -it --rm onjin/alpine-postgres:9.4 psql -U postgres -h 172.17.0.4
psql (9.4.5, server 9.3.11)
Type "help" for help.

postgres=# \q

onjin@nazano:~ (py-2.7.6)
 $ docker run -it --rm onjin/alpine-postgres:9.5 psql -U postgres -h 172.17.0.4
psql (9.5.1, server 9.3.11)
Type "help" for help.

postgres=#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment