{"id":4470,"date":"2016-08-16T10:12:47","date_gmt":"2016-08-16T01:12:47","guid":{"rendered":"http:\/\/www.lancard.com\/blog\/?p=4470"},"modified":"2025-03-12T11:27:07","modified_gmt":"2025-03-12T02:27:07","slug":"docker%e5%85%ac%e5%bc%8f%e3%82%a4%e3%83%a1%e3%83%bc%e3%82%b8%e3%81%a7%e9%96%8b%e7%99%ba%e7%94%a8rdb%e3%82%92%e3%82%b2%e3%83%83%e3%83%88%e3%81%a0%e3%81%9cpostgresql%e7%b7%a8","status":"publish","type":"post","link":"https:\/\/www.lancard.com\/blog\/2016\/08\/16\/docker%e5%85%ac%e5%bc%8f%e3%82%a4%e3%83%a1%e3%83%bc%e3%82%b8%e3%81%a7%e9%96%8b%e7%99%ba%e7%94%a8rdb%e3%82%92%e3%82%b2%e3%83%83%e3%83%88%e3%81%a0%e3%81%9cpostgresql%e7%b7%a8\/","title":{"rendered":"Docker\u516c\u5f0f\u30a4\u30e1\u30fc\u30b8\u3067\u958b\u767a\u7528RDB\u3092\u30b2\u30c3\u30c8\u3060\u305c(PostgreSQL\u7de8)"},"content":{"rendered":"<h1>\u307e\u3048\u304c\u304d<\/h1>\n<p>Laravel\u3067\u306e\u958b\u767a\u6642\u306b\u30c7\u30d7\u30ed\u30a4\u5148\u306fMySQL\u306a\u306e\u306b\u624b\u3092\u629c\u3044\u3066\u624b\u5143\u306e\u958b\u767a\u6a5f\u3067\u306fSQLite\u3092\u4f7f\u3063\u3066\u3044\u305f\u3089\u75db\u3044\u76ee\u306b\u3042\u3063\u305f\u308a\u3057\u307e\u3057\u305f\u3001murave\u3067\u3059\u3002<\/p>\n<blockquote class=\"twitter-tweet\" data-lang=\"ja\">\n<p lang=\"ja\" dir=\"ltr\">SQLite\u3063\u3066\u7d50\u69cb\u30eb\u30fc\u30ba\u306b\u3064\u304b\u3048\u3066\u3057\u307e\u3046\u306e\u3067\u624b\u5143\u306e\u958b\u767a\u3067SQLite\u4f7f\u3063\u3066\u3066MySQL\u904b\u7528\u306e\u30b5\u30fc\u30d0\u30fc\u306b\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u3068\u30a8\u30e9\u30fc\u304c\u30d0\u30f3\u30d0\u30f3\u3068\u3044\u3046\u306e\u304c\u6628\u65e5\u304b\u3089\u9023\u7d9a\u767a\u751f\u4e2d\u3002<\/p>\n<p>&mdash; murave (@murave) <a href=\"https:\/\/twitter.com\/murave\/status\/753415995830657024\">2016\u5e747\u670814\u65e5<\/a><\/p><\/blockquote>\n<p><script async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n<p>\u958b\u767a\u74b0\u5883\u306b\u3042\u307e\u308a\u5f71\u97ff\u3092\u4e0e\u3048\u305a\u306b\u30b5\u30af\u30c3\u3068\u958b\u767a\u7528\u306eRDB(Relational Database)\u3092\u5efa\u3066\u3089\u308c\u308b\u3068\u7d20\u6575\u3067\u3059\u306d\u3002Docker\u516c\u5f0f\u30a4\u30e1\u30fc\u30b8\u3092\u6d3b\u7528\u3059\u308b\u3068\u51fa\u6765\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>RDB\u3068\u3044\u3046\u30c7\u30c3\u30ab\u30a4\u5358\u8a9e\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u81ea\u5206\u304c\u3088\u304f\u4f7f\u3046PostgreSQL\u3001MySQL\u3001MariaDB\u306a\u3069\u306b\u3064\u3044\u3066\u8abf\u3079\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002MySQL\u3068MariaDB\u81ea\u4f53\u306f\u307b\u307c\u540c\u3058\u6271\u3044\u65b9\u304c\u3067\u304d\u308bRDB\u3067\u3059\u304c\u3001\u516c\u5f0f\u30a4\u30e1\u30fc\u30b8\u3067\u306e\u6271\u3044\u306f\u3069\u3046\u306a\u3093\u3067\u3057\u3087\u3046\u306d\u3002<\/p>\n<p>\u8a18\u4e8b\u306b\u307e\u3068\u3081\u306a\u304c\u3089\u8a66\u3057\u3066\u3044\u3053\u3046\u3068\u601d\u3044\u307e\u3059\u3002Docker for Mac\u3092\u4f7f\u7528\u3057\u3066\u304a\u308a\u3001\u4eca\u56de\u306fPostgreSQL\u3067\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<h1>PostgreSQL<\/h1>\n<h2>\u516c\u5f0f\u30a4\u30e1\u30fc\u30b8\u3092\u8abf\u3079\u308b<\/h2>\n<p><a href=\"https:\/\/hub.docker.com\/_\/postgres\/\" target=\"_blank\">OFFICIAL REPOSITORY postgres<\/a><\/p>\n<p>2016\u5e748\u6708\u4e2d\u65ec\u73fe\u5728\u3001\u4ee5\u4e0b\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u3042\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>9.6(9.6-beta4) , 9.5(9.5.4),  9.4(9.4.9), 9.3(9.3.14), 9.2(9.2.18), 9.1(9.1.23)<\/p>\n<p>\u6d41\u77f3\u306b8\u7cfb\u306f\u306a\u3044\u3067\u3059\u306d\u3002\u4f7f\u3044\u305f\u304f\u306a\u3044\u3067\u3059\u3088\u306d\u3002\u5fd8\u308c\u307e\u3057\u3087\u3046\u3002\u5ba2\u5148\u306b\u306f\u6b8b\u3063\u3066\u307e\u3059\u304c\u3002<\/p>\n<h3>\u8d77\u52d5\u3059\u308b<\/h3>\n<p>\u8a66\u3057\u3066\u3044\u304d\u307e\u3059\u3002\u305b\u3063\u304b\u304f\u3067\u3059\u304b\u30899.6\u3067\u3084\u3063\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<pre><code>$ docker run -d --name postgres96beta4 -e POSTGRES_PASSWORD=mysecretpassword -p 15432:5432 postgres:9.6\n<\/code><\/pre>\n<p>\u516c\u5f0f\u306e\u4f8b\u3092\u53c2\u8003\u306b\u30b3\u30f3\u30c6\u30ca\u306e5432\u309215432\u306b\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c9\u306a\u3069\u8ffd\u52a0\u3057\u3066\u304a\u304d\u307e\u3057\u305f\u3002<\/p>\n<h3>\u63a5\u7d9a\u3059\u308b<\/h3>\n<p>psql\u3067\u306e\u63a5\u7d9a\u3067\u3059\u304c\u3001\u516c\u5f0f\u306b\u306f\u5225\u30b3\u30f3\u30c6\u30ca\u3092\u7acb\u3061\u4e0a\u3052\u3066\u306e\u63a5\u7d9a\u4f8b\u304c\u8f09\u3063\u3066\u307e\u3059\u306d\u3002<\/p>\n<pre><code>$ docker run -it --rm --link postgres96beta4:postgres postgres:9.6 psql -h postgres -U postgres\nPassword for user postgres: \npsql (9.6beta4)\nType \"help\" for help.\n\npostgres=# select version();\n                                           version                                           \n---------------------------------------------------------------------------------------------\n PostgreSQL 9.6beta4 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit\n(1 row)\n\npostgres=# \\l\n                                 List of databases\n   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   \n-----------+----------+----------+------------+------------+-----------------------\n postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | \n template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c\/postgres          +\n           |          |          |            |            | postgres=CTc\/postgres\n template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c\/postgres          +\n           |          |          |            |            | postgres=CTc\/postgres\n(3 rows)\n\npostgres=# \\q\n<\/code><\/pre>\n<p>&#8211;rm \u3092\u4ed8\u3051\u3066\u3042\u308b\u306e\u3067\u629c\u3051\u308b\u3068\u30b3\u30f3\u30c6\u30ca\u306f\u6d88\u3048\u307e\u3059\u3002\u511a\u3044\u3002<\/p>\n<p>\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c9\u3057\u3066\u3042\u308b\u306e\u3067Mac\u304b\u3089\u3064\u306a\u3050\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u304c\u3001\u5f53\u7136\u3001psql\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306fMac\u4e0a\u306e\u3082\u306e\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code>$ psql -h localhost -p 15432 -U postgres                      \nPassword for user postgres: \npsql (9.3.5, server 9.6beta4)\nWARNING: psql major version 9.3, server major version 9.6.\n         Some psql features might not work.\nType \"help\" for help.\n\npostgres=# \\q\n<\/code><\/pre>\n<p>9.3\u7528\u306a\u306e\u3067\u8b66\u544a\u304c\u3067\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u611b\u3057\u306epgAdmin3\u3067\u3064\u306a\u3044\u3067\u307f\u307e\u3057\u3087\u3046\u3002pgAdmin3\u30829.3\u7528\u306a\u306e\u3067\u8b66\u544a\u3055\u308c\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/www.lancard.com\/blog\/wp-content\/uploads\/2016\/08\/87b8315195c0206707a6ae30c992d9ae.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.lancard.com\/blog\/wp-content\/uploads\/2016\/08\/87b8315195c0206707a6ae30c992d9ae-400x258.jpg\" alt=\"pgAdmin3\u3067Docker\u30b3\u30f3\u30c6\u30ca\u4e0a\u306ePostgreSQL\u306b\u63a5\u7d9a(\u30d0\u30fc\u30b8\u30e7\u30f3\u8b66\u544a)\" width=\"400\" height=\"258\" class=\"alignnone size-medium wp-image-4476\" srcset=\"https:\/\/www.lancard.com\/blog\/wp-content\/uploads\/2016\/08\/87b8315195c0206707a6ae30c992d9ae-400x258.jpg 400w, https:\/\/www.lancard.com\/blog\/wp-content\/uploads\/2016\/08\/87b8315195c0206707a6ae30c992d9ae-768x496.jpg 768w, https:\/\/www.lancard.com\/blog\/wp-content\/uploads\/2016\/08\/87b8315195c0206707a6ae30c992d9ae-602x389.jpg 602w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>\u63a5\u7d9a\u306f\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"http:\/\/www.lancard.com\/blog\/wp-content\/uploads\/2016\/08\/9e2a837ca52d693ec0e2dfed7cf27c66.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.lancard.com\/blog\/wp-content\/uploads\/2016\/08\/9e2a837ca52d693ec0e2dfed7cf27c66-400x257.jpg\" alt=\"pgAdmin3\u3067Docker\u30b3\u30f3\u30c6\u30ca\u4e0a\u306ePostgreSQL\u306b\u63a5\u7d9a\u3057\u3066\u64cd\u4f5c\" width=\"400\" height=\"257\" class=\"alignnone size-medium wp-image-4477\" srcset=\"https:\/\/www.lancard.com\/blog\/wp-content\/uploads\/2016\/08\/9e2a837ca52d693ec0e2dfed7cf27c66-400x257.jpg 400w, https:\/\/www.lancard.com\/blog\/wp-content\/uploads\/2016\/08\/9e2a837ca52d693ec0e2dfed7cf27c66-768x494.jpg 768w, https:\/\/www.lancard.com\/blog\/wp-content\/uploads\/2016\/08\/9e2a837ca52d693ec0e2dfed7cf27c66-602x387.jpg 602w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>\u307b\u307c\u4f7f\u3048\u307e\u3057\u305f\u304cPostgreSQL9.6\u306b\u5bfe\u3057\u3066\u30c4\u30fc\u30eb\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c9.3\u7528\u3068\u53e4\u3044\u306e\u3067\u30a8\u30e9\u30fc\u304c\u3067\u305f\u308a\u3082\u3057\u307e\u3059\u306d\u3002<br \/>\npsql\u306e\u307f\u3067\u4f5c\u696d\u3059\u308b\u306e\u306f\u30c4\u30e9\u30a4\u306e\u3067\u30c4\u30fc\u30eb\u306f\u5bfe\u8c61\u306b\u5408\u308f\u305b\u305f\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u7528\u610f\u3057\u306a\u3044\u3068\u3042\u304b\u3093\u306a\u3041\u3068\u601d\u3044\u307e\u3057\u305f\u3002<\/p>\n<h3>\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306a\u3069<\/h3>\n<p>\u30b3\u30f3\u30c6\u30ca\u306e\u30b7\u30a7\u30eb\u3092\u8d77\u52d5\u3057\u3066\u63a2\u691c\u3002<\/p>\n<pre><code>$ docker exec -it postgres96beta4 bash  \nroot@d2e991bd61a7:\/# cd \/var\/lib\/postgresql\/data\/\nroot@d2e991bd61a7:\/var\/lib\/postgresql\/data# more postgresql.conf \n<\/code><\/pre>\n<p>\u3068\u3001\u3053\u306e\u3088\u3046\u306bpostgresql.conf\u3092\u773a\u3081\u3066\u307f\u305f\u308a(less\u3082vi\u3082\u306a\u304b\u3063\u305f)\u3002<\/p>\n<pre><code>root@d2e991bd61a7:\/var\/lib\/postgresql\/data# more pg_hba.conf\n<\/code><\/pre>\n<p>pg_hba.conf\u3092\u773a\u3081\u3066\u307f\u305f\u308a\u3002pg_hba.conf\u304b\u3089\u629c\u7c8b\u3057\u307e\u3059\u3068<\/p>\n<pre><code># TYPE  DATABASE        USER            ADDRESS                 METHOD\n# \"local\" is for Unix domain socket connections only\nlocal   all             all                                     trust\n# IPv4 local connections:\nhost    all             all             127.0.0.1\/32            trust\n# IPv6 local connections:\nhost    all             all             ::1\/128                 trust\n\nhost all all 0.0.0.0\/0 md5\n<\/code><\/pre>\n<p>\u30ed\u30fc\u30ab\u30eb\u304b\u3089\u306ftrust\u3067\u4ed6\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u8a8d\u8a3c\u3067\u3059\u304b\u306d\u3002<\/p>\n<h3>\u62e1\u5f35\u3059\u308b<\/h3>\n<p>\u30b3\u30f3\u30c6\u30ca\u306e \/docker-entrypoint-initdb.d \u306b\u62e1\u5f35\u5b50\u304csql\u3001sh\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u7f6e\u304f\u3068\u30b3\u30f3\u30c6\u30ca\u8d77\u52d5\u6642\u306b\u5b9f\u884c\u3057\u3066\u304f\u308c\u308b\u305d\u3046\u3067\u3059\u3002<br \/>\n\u4ed6\u3001Dockerfile\u3067default locale\u3092\u8a2d\u5b9a\u3059\u308b\u3068\u3044\u3046\u4f8b\u304c\u516c\u5f0f\u306e\u30da\u30fc\u30b8\u306b\u4f8b\u3068\u3057\u3066\u8f09\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3084\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<h4>\u65e5\u672c\u8a9e\u5316\u3055\u308c\u305f\u30a4\u30e1\u30fc\u30b8\u306e\u4f5c\u6210<\/h4>\n<p>default locale\u3092\u8a2d\u5b9a\u3059\u308bDockerfile\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<p>Dockerfile<\/p>\n<pre><code>FROM postgres:9.6\n\nMAINTAINER murave\n\nRUN localedef -i ja_JP -c -f UTF-8 -A \/usr\/share\/locale\/locale.alias ja_JP.UTF-8\nENV LANG ja_JP.utf8\n<\/code><\/pre>\n<p>\u65e5\u672c\u8a9e\u5316\u3055\u308c\u305f\u30a4\u30e1\u30fc\u30b8\u3001mypostgres:9.6\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<pre><code>$ docker build -t mypostgres:9.6 .\/\n<\/code><\/pre>\n<p>\u78ba\u8a8d<\/p>\n<pre><code>$ docker images\nREPOSITORY           TAG                 IMAGE ID            CREATED             SIZE\nmypostgres           9.6                 4b7ea9f892dd        24 seconds ago      269.2 MB\n<\/code><\/pre>\n<h4>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u521d\u671f\u5316<\/h4>\n<p>\u64cd\u4f5c\u3057\u3066\u3044\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\/docker-entrypoint-initdb.d\u5bfe\u5fdc\u7528\u306binitdb\u3068\u3044\u3046\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002postgres\/9.6\/docker-entrypoint.sh \u3092\u8aad\u3093\u3067\u307f\u305f\u3068\u3053\u308d<\/p>\n<pre><code>for f in \/docker-entrypoint-initdb.d\/*; do\n    case \"$f\" in\n        *.sh)     echo \"$0: running $f\"; . \"$f\" ;;\n        *.sql)    echo \"$0: running $f\"; \"${psql[@]}\" &lt; \"$f\"; echo ;;\n        *.sql.gz) echo \"$0: running $f\"; gunzip -c \"$f\" | \"${psql[@]}\"; echo ;;\n        *)        echo \"$0: ignoring $f\" ;;\n    esac\n    echo\ndone\n<\/code><\/pre>\n<p>\u3067\u9806\u6b21\u51e6\u7406\u3068\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u30d5\u30a1\u30a4\u30eb\u540d\u9806\u306b\u5b9f\u884c\u3055\u308c\u308b\u3088\u3046\u3067\u3059\u3002sql\u3092gzip\u5727\u7e2e\u3057\u305fsql.gz\u62e1\u5f35\u5b50\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u3082\u5bfe\u5fdc\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u306d\u3002<\/p>\n<p>\u521d\u671f\u5316\u6642\u306bdocker\u30e6\u30fc\u30b6\u30fc\u3068docker\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3059\u308bsh\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>initdb\/01adduser.sh<\/p>\n<pre><code>#!\/bin\/bash\nset -e\n\npsql -v ON_ERROR_STOP=1 --username \"$POSTGRES_USER\" &lt;&lt;-EOSQL\n    CREATE USER docker;\n    ALTER USER docker WITH PASSWORD 'dockerpassword';\n    CREATE DATABASE docker;\n    GRANT ALL PRIVILEGES ON DATABASE docker TO docker;\nEOSQL\n<\/code><\/pre>\n<p>\u6b21\u306bsql\u30d5\u30a1\u30a4\u30eb\u5185\u3067\\c\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068\u30e6\u30fc\u30b6\u30fc\u3092docker\u306b\u5207\u308a\u66ff\u3048\u3066\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u3063\u3066\u307f\u307e\u3059\u3002sh\u3067db\u63a5\u7d9a\u304b\u3089\u3057\u305f\u307b\u3046\u304c\u7c21\u5358\u306a\u6c17\u304c\u3057\u307e\u3059\u304c\u3001\u5b9f\u9a13\u3067\u3059\u3002<\/p>\n<p>initdb\/02createtb.sql<\/p>\n<pre><code>\\c docker docker\n\nCREATE TABLE auth_group (\n    id integer NOT NULL,\n    name character varying(80) NOT NULL\n);\n\nCOPY auth_group (id, name) FROM stdin;\n1   Gyoumu\n2   Master\n3   System\n\\.\n<\/code><\/pre>\n<p>\u65e5\u672c\u8a9e\u5316\u3057\u305fmypostgres:9.6\u304b\u3089Mac\u306einitdb\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\/docker-entrypoint-initdb.d\u306b\u30d0\u30a4\u30f3\u30c9\u3057\u3066\u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre><code>$ docker run -d --name postgres96beta4 -e POSTGRES_PASSWORD=mysecretpassword -p 15432:5432 -v $(pwd)\/initdb:\/docker-entrypoint-initdb.d mypostgres:9.6\n<\/code><\/pre>\n<p>psql\u3067\u7e4b\u3044\u3067\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3059(\u4e00\u5fdcmypostgres:9.6\u30a4\u30e1\u30fc\u30b8\u306e\u65b9\u306e\u3082\u306e\u3092\u4f7f\u7528)\u3002<\/p>\n<pre><code>$ docker run -it --rm --link postgres96beta4:postgres mypostgres:9.6 psql -h postgres -U postgres\n\u30e6\u30fc\u30b6 postgres \u306e\u30d1\u30b9\u30ef\u30fc\u30c9: \npsql (9.6beta4)\n\"help\" \u3067\u30d8\u30eb\u30d7\u3092\u8868\u793a\u3057\u307e\u3059.\n\npostgres=# \\l\n docker    | postgres | UTF8             | ja_JP.utf8 | ja_JP.utf8        | =Tc\/postgres         +\n           |          |                  |            |                   | postgres=CTc\/postgres+\n           |          |                  |            |                   | docker=CTc\/postgres\n postgres  | postgres | UTF8             | ja_JP.utf8 | ja_JP.utf8        | \n template0 | postgres | UTF8             | ja_JP.utf8 | ja_JP.utf8        | =c\/postgres          +\n           |          |                  |            |                   | postgres=CTc\/postgres\n template1 | postgres | UTF8             | ja_JP.utf8 | ja_JP.utf8        | =c\/postgres          +\n           |          |                  |            |                   | postgres=CTc\/postgres\n\npostgres=# \\c docker docker\n\u30e6\u30fc\u30b6 docker \u306e\u30d1\u30b9\u30ef\u30fc\u30c9: \n\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9 \"docker\" \u306b\u30e6\u30fc\u30b6\"docker\"\u3068\u3057\u3066\u63a5\u7d9a\u3057\u307e\u3057\u305f\u3002\ndocker=&gt; \\dt\n public   | auth_group | \u30c6\u30fc\u30d6\u30eb | docker\n\ndocker=&gt; select * from auth_group;\n  1 | Gyoumu\n  2 | Master\n  3 | System\n\ndocker=&gt; \\q\n<\/code><\/pre>\n<p>\u65e5\u672c\u8a9e\u5316\u3055\u308c\u305f\u30a4\u30e1\u30fc\u30b8\u3092\u5143\u306b\u300101adduser.sh\u3067docker\u30e6\u30fc\u30b6\u30fc\u3092\u4f5c\u6210\u3057\u3066\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\u3001docker\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u308a\u300102createtb.sql\u3067docker\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9docker\u30e6\u30fc\u30b6\u30fc\u306b\u5207\u308a\u66ff\u3048\u3066auth_group\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u3001\u30c7\u30fc\u30bf\u3092\u6d41\u3057\u8fbc\u3081\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<h2>Docker Compose \u3067\u958b\u767a\u7528\u306e PostgreSQL \u3092\u8d77\u52d5\u3059\u308b<\/h2>\n<p>\u65e5\u672c\u8a9e\u5316\u3057\u305f\u30a4\u30e1\u30fc\u30b8\u3092\u4f7f\u7528\u3057\u3001initdb\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u521d\u671f\u5316\u3001\u30c7\u30fc\u30bf\u306e\u6c38\u7d9a\u5316\u306fbusybox\u3092\u4f7f\u7528\u3059\u308b\u65b9\u91dd\u3067docker-compose.yml\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/qiita.com\/astrsk_hori\/items\/1e683a7a2f2b7189cb6e\" target=\"_blank\">docker-compose\u3067mysql &amp; postgreSQL \u3092\u30b5\u30af\u30c3\u3068\u8d77\u52d5<\/a><\/p>\n<p>\u3092\u53c2\u8003\u306b\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>docker-compose.yml<\/p>\n<pre><code>postgres-data:\n  image: busybox\n  volumes:\n      - \/var\/lib\/postgresql\/data\n  container_name: postgres-datastore\n\npostgresql:\n  image: mypostgres:9.6\n  environment:\n      POSTGRES_USER: postgres\n      POSTGRES_PASSWORD: mysecretpassword\n  volumes:\n      - .\/initdb\/:\/docker-entrypoint-initdb.d\n  ports:\n      - \"15432:5432\"\n  container_name: postgres-db\n  volumes_from:\n      - postgres-data\n<\/code><\/pre>\n<p>\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre><code>$ docker-compose up -d\nCreating postgres-datastore\nCreating postgres-db\n<\/code><\/pre>\n<p>\u4ee5\u964d\u3001\u4f7f\u7528\u3059\u308b\u3042\u3044\u3060\u306fstop\u30fbstart\u3067\u505c\u6b62\u30fb\u8d77\u52d5\u3057\u3066\u3044\u304f\u611f\u3058\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>psql\u3084pgAdmin3\u3067\u52d5\u4f5c\u78ba\u8a8d\u3002OK\u3067\u3057\u305f\u306e\u3067\u3053\u308c\u304b\u3089\u306f\u30b3\u30ec\u3092\u30d9\u30fc\u30b9\u306b\u8abf\u6574\u3059\u308c\u3070\u7c21\u5358\u306bPostgreSQL\u3092\u6e96\u5099\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d5\u30a1\u30a4\u30eb\u69cb\u6210\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<pre><code class=\"text\">.\n\u251c\u2500\u2500 Dockerfile\n\u251c\u2500\u2500 docker-compose.yml\n\u2514\u2500\u2500 initdb\n    \u251c\u2500\u2500 01adduser.sh\n    \u2514\u2500\u2500 02createtb.sql\n<\/code><\/pre>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F4470&#038;t=Docker%E5%85%AC%E5%BC%8F%E3%82%A4%E3%83%A1%E3%83%BC%E3%82%B8%E3%81%A7%E9%96%8B%E7%99%BA%E7%94%A8RDB%E3%82%92%E3%82%B2%E3%83%83%E3%83%88%E3%81%A0%E3%81%9C%28PostgreSQL%E7%B7%A8%29&#038;s=100&#038;p&#091;url&#093;=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F4470&#038;p&#091;images&#093;&#091;0&#093;=http%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-content%2Fuploads%2F2016%2F08%2F87b8315195c0206707a6ae30c992d9ae-400x258.jpg&#038;p&#091;title&#093;=Docker%E5%85%AC%E5%BC%8F%E3%82%A4%E3%83%A1%E3%83%BC%E3%82%B8%E3%81%A7%E9%96%8B%E7%99%BA%E7%94%A8RDB%E3%82%92%E3%82%B2%E3%83%83%E3%83%88%E3%81%A0%E3%81%9C%28PostgreSQL%E7%B7%A8%29\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/facebook.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"http:\/\/twitter.com\/share?url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F4470&#038;text=Docker%E5%85%AC%E5%BC%8F%E3%82%A4%E3%83%A1%E3%83%BC%E3%82%B8%E3%81%A7%E9%96%8B%E7%99%BA%E7%94%A8RDB%E3%82%92%E3%82%B2%E3%83%83%E3%83%88%E3%81%A0%E3%81%9C%28PostgreSQL%E7%B7%A8%29\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F4470&#038;title=Docker%E5%85%AC%E5%BC%8F%E3%82%A4%E3%83%A1%E3%83%BC%E3%82%B8%E3%81%A7%E9%96%8B%E7%99%BA%E7%94%A8RDB%E3%82%92%E3%82%B2%E3%83%83%E3%83%88%E3%81%A0%E3%81%9C%28PostgreSQL%E7%B7%A8%29\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/linkedin.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-tumblr nolightbox\" data-provider=\"tumblr\" target=\"_blank\" rel=\"nofollow\" title=\"Share on tumblr\" href=\"https:\/\/tumblr.com\/share?s=&#038;v=3&#038;t=Docker%E5%85%AC%E5%BC%8F%E3%82%A4%E3%83%A1%E3%83%BC%E3%82%B8%E3%81%A7%E9%96%8B%E7%99%BA%E7%94%A8RDB%E3%82%92%E3%82%B2%E3%83%83%E3%83%88%E3%81%A0%E3%81%9C%28PostgreSQL%E7%B7%A8%29&#038;u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F4470\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"tumblr\" title=\"Share on tumblr\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/tumblr.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=Docker%E5%85%AC%E5%BC%8F%E3%82%A4%E3%83%A1%E3%83%BC%E3%82%B8%E3%81%A7%E9%96%8B%E7%99%BA%E7%94%A8RDB%E3%82%92%E3%82%B2%E3%83%83%E3%83%88%E3%81%A0%E3%81%9C%28PostgreSQL%E7%B7%A8%29&#038;body=%E3%82%B7%E3%82%A7%E3%82%A2%E3%81%99%E3%82%8B%EF%BC%9A:%20https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F4470\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>\u307e\u3048\u304c\u304d Laravel\u3067\u306e\u958b\u767a\u6642\u306b\u30c7\u30d7\u30ed\u30a4\u5148\u306fMySQL\u306a\u306e\u306b\u624b\u3092\u629c\u3044\u3066\u624b\u5143\u306e\u958b\u767a\u6a5f\u3067\u306fSQLite\u3092\u4f7f\u3063\u3066\u3044\u305f\u3089\u75db\u3044\u76ee\u306b\u3042\u3063\u305f\u308a\u3057\u307e\u3057\u305f\u3001murave\u3067\u3059\u3002 SQLite\u3063\u3066\u7d50\u69cb\u30eb\u30fc\u30ba\u306b\u3064\u304b\u3048\u3066\u3057\u307e\u3046\u306e\u3067\u624b\u5143\u306e\u958b\u767a\u3067 [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48,13],"tags":[153,135],"class_list":["post-4470","post","type-post","status-publish","format-standard","hentry","category-mac","category-postgresql","tag-docker","tag-postgresql"],"_links":{"self":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/4470","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/comments?post=4470"}],"version-history":[{"count":9,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/4470\/revisions"}],"predecessor-version":[{"id":4481,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/4470\/revisions\/4481"}],"wp:attachment":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/media?parent=4470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/categories?post=4470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/tags?post=4470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}