このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン 次のリビジョン 両方とも次のリビジョン | ||
ソフトウェア:docker:docker-compose.yml_dockerfile_作成例:centos8_mysql8.0 [2019/10/30 11:16] humolife |
ソフトウェア:docker:docker-compose.yml_dockerfile_作成例:centos8_mysql8.0 [2020/11/09 18:39] humolife [docker/db/conf.d/my.cnf] |
||
---|---|---|---|
行 6: | 行 6: | ||
├ docker | ├ docker | ||
│ ├ app | │ ├ app | ||
- | │ │ ├ htdocs | ||
- | │ │ │ └ .htaccess | ||
│ │ └ Dockerfile | │ │ └ Dockerfile | ||
│ ├ db | │ ├ db | ||
│ │ ├ conf.d | │ │ ├ conf.d | ||
- | │ │ │ └ my.cnf | + | │ │ │ └ charset.cnf |
│ │ └ Dockerfile | │ │ └ Dockerfile | ||
│ └ docker-compose.yml | │ └ docker-compose.yml | ||
行 39: | 行 37: | ||
ports: | ports: | ||
- 8080:80 | - 8080:80 | ||
- | links: | ||
- | - db: | ||
volumes: | volumes: | ||
- ../ | - ../ | ||
行 53: | 行 49: | ||
===== docker/ | ===== docker/ | ||
< | < | ||
- | FROM centos:latest | + | FROM centos:8 |
- | RUN dnf -y update && dnf -y install httpd | + | RUN dnf -y update && |
+ | | ||
+ | dnf -y install epel-release && \ | ||
+ | dnf -y install https:// | ||
+ | rpm -ivh http:// | ||
+ | dnf module install -y php: | ||
+ | dnf -y install php-pdo php-json php-xml php-mysqlnd php-gd php-mbstring && \ | ||
+ | dnf -y localinstall https:// | ||
+ | dnf -y install mysql-server && \ | ||
+ | dnf -y install crontabs | ||
- | RUN dnf -y install epel-release | + | RUN rm -rf / |
+ | ln -s / | ||
- | RUN dnf -y install https:// | + | # httpd |
+ | RUN systemctl enable httpd | ||
+ | </code> | ||
- | RUN rpm -ivh http:// | ||
- | RUN dnf module install -y php:remi-7.3 | + | ===== docker/ |
- | RUN dnf install -y php-pdo php-json php-xml php-mysqlnd php-gd php-mbstring | + | < |
+ | FROM mysql:8.0 | ||
- | COPY ./ | + | RUN apt-get update && \ |
+ | apt-get -y install locales-all | ||
- | RUN ln -s / | + | ENV LANG ja_JP.UTF-8 \ |
+ | LANGUAGE ja_JP:ja | ||
- | # MySQL | + | COPY ./conf.d/charset.cnf /etc/my.cnf.d/ |
- | RUN dnf -y localinstall https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm | + | |
- | + | ||
- | RUN dnf -y install mysql-server | + | |
- | + | ||
- | # cron | + | |
- | RUN dnf -y install crontabs | + | |
- | + | ||
- | # httpd | + | |
- | RUN systemctl enable httpd | + | |
</ | </ | ||
- | ===== docker/app/htdocs/.htaccess | + | ===== docker/db/conf.d/charset.cnf ===== |
< | < | ||
- | RewriteEngine On | + | [mysqld] |
- | RewriteRule ^(.*)$ pj/$1 [QSA,L] | + | character-set-server = utf8mb4 |
- | </ | + | collation-server = utf8mb4_bin |
+ | init-connect=' | ||
- | ===== docker/ | + | [client] |
- | < | + | loose-default-character-set |
- | FROM mysql: | + | |
- | COPY ./conf.d / | + | |
</ | </ | ||
- | ===== docker/ | + | ===== コマンドの実行 |
+ | Docker Quickstart Terminal を起動する。 | ||
< | < | ||
- | [mysqld] | + | # project/docker ディレクトリへ移動 |
- | # Character code setting | + | cd project/ |
- | character_set_server=utf8mb4 | + | |
- | collation-server=utf8mb4_bin | + | |
- | default_authentication_plugin= mysql_native_password | + | # コンテナの作成&起動 |
+ | # -d をつけることでバックグラウンドでコンテナを起動 | ||
+ | # --build をつけることでイメージを作成 | ||
+ | docker-compose up -d --build | ||
- | [mysql] | + | # コンテナの一覧を確認 |
- | default-character-set=utf8mb4 | + | docker-compose ps |
- | </ | + | |
+ | # IP アドレスを調べる | ||
+ | docker-machine ip | ||
+ | |||
+ | # 192.168.99.100 なら、以下でアクセス可能になる | ||
+ | # http:// | ||
+ | |||
+ | # 2回め以降は、バックグラウンドでコンテナを起動するだけでよい | ||
+ | docker-compose up -d | ||
+ | |||
+ | # app コンテナに入り作業をする | ||
+ | docker container exec -it laravel_app_sample /bin/bash | ||
+ | |||
+ | # マウントした production に移動 | ||
+ | cd / | ||
+ | |||
+ | # production ディレクトリ内のファイルが共有されているか確認 | ||
+ | ls -l | ||
+ | |||
+ | # db コンテナの DB に接続できるか確認 | ||
+ | mysql -h laravel_db_sample --port 3306 -u docker -pdocker -D laravel_db | ||
+ | </ | ||