C:\Users\ebata>docker pull postgres:12.2
12.2: Pulling from library/postgres
bc51dd8edc1b: Pull complete
d2b355dbb6c6: Pull complete
d237363a1a91: Pull complete
ff4b9d2fde66: Pull complete
646492d166e7: Pull complete
828b1f103a3a: Pull complete
2ab9e3c9583f: Pull complete
4ab234e8a047: Pull complete
71b084e0c62f: Pull complete
bf30bd092a82: Pull complete
2aa61e9feb4e: Pull complete
aa5eca126d57: Pull complete
7046b64d69a3: Pull complete
a851dbb990ce: Pull complete
Digest: sha256:c5423e0febf82c33b5dc69aacd70d64418144db7bd355fa4ca30e6e5430b4123
Status: Downloaded newer image for postgres:12.2
docker.io/library/postgres:12.2
C:\Users\ebata>docker run -d --name postgres122 -e POSTGRES_PASSWORD=test -p 5432:5432 postgres:12.2
839317f0bb705daf5eac55cc6b4f74e0cbc49ff2f64e1efc9dd5e4d3f03e6515
C:\Users\ebata>docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
839317f0bb70 postgres:12.2 "docker-entrypoint.s…" 17 seconds ago Up 14 seconds 0.0.0.0:5432->5432/tcp postgres122
C:\Users\ebata>docker exec -ti postgres122 bash
2.準備
Windows10 BOX のC:\直下に、routing-20200221.sql を置いておく
3.ファイルのコピー
C:\Users\ebata>docker cp c:\routing-20200221.sql postgres122:/tmp/
でDockerの内部にコピー
4.コンテナに入る
C:\Users\ebata>docker exec -i -t postgres122 /bin/bash
5.コピーされているかを確認する
root@839317f0bb70:/# cd tmp
root@839317f0bb70:/tmp# ls
で、
routing-20200221.sql
が表示されたので成功
6.ローカルにdocker-compose.ymlを作成する
version: '3.7'
services:
db:
image: pgrouting/pgrouting:v3.0.0-dev-postgresql_12
expose:
- 5432
ports:
- 15432:5432
volumes:
- db_data
- ./shared:/shared
db_data:
image: busybox
volumes:
- /data/db
8.次のコマンドを実施する
C:\Users\ebata>docker-compose up -d
9.DBの作成
C:\Users\ebata>docker-compose exec db createdb -h db -U postgres routing
10.postgisのインストール
C:\Users\ebata>docker-compose exec db psql -h db -U postgres -d routing -c 'CREATE EXTENSION pgrouting CASCADE; CREATE EXTENSION hstore;'
11.ダンプしたsqlの取り込み
C:\Users\ebata>docker-compose exec db psql -h db -U postgres routing -f /shared/routing-20200221.sql