Docker コンテナ実行の流れ $ docker run hello-world Hello from Docker! This message shows that your installation appears to be working correctly. (snip) docker run コマンドでイメージからコンテナを生成して実行 hello-world : 実行するイメージ
hello-world 出力メッセージ To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.(amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
Docker サーバ コンテナ実行ランタイム Linux コンテナでは、Linux カーネルが必要 Docker for Mac は、Linux VM を内包 (HyperKit) Docker クライアント docker コマンド 各 OS ネイティブアプリケーション リモートホストの Docker デーモンも操作可
ホストの psql で接続 $ psql --version psql (PostgreSQL) 9.6.5 $ psql -Upostgres -h localhost psql (9.6.5, server 10.5 (Debian 10.5-1.pgdg90+1)) WARNING: psql major version 9.6, server major version 10. Some psql features might not work. Type "help" for help. postgres=#
ロケールを設定するイメージを作成 Docker le # ベースイメージ FROM postgres:10 # ロケール設定 RUN localedef -i ja_JP -c -f UTF-8 \ -A /usr/share/locale/locale.alias ja_JP.UTF-8 # 環境変数 LANG 設定 ENV LANG ja_JP.utf8
コンテナを破棄して、再実行しても残っている $ docker run docker run --rm --name db -p 5432:5432 -v `pwd`/pgdata:/var/lib/postgresql/data postgres $ docker exec -it db psql -Upostgres postgres=# \d List of relations Schema | Name | Type | Owner --------+--------------+----------+---------- public | users | table | postgres public | users_id_seq | sequence | postgres (2 rows)
make を実行するだけ 環境がセットアップ後に自動テストでチェック テストが通る状態から開発開始 $ make docker-compose up -d Creating network "web-application_default" with the default driver Creating web-application_db_1 ... done (snip) PHPUnit 7.1.2 by Sebastian Bergmann and contributors. ..................... 21 / 21 (100%) Time: 6.24 seconds, Memory: 20.00MB OK (21 tests, 53 assertions)