cd compose_lnmpdocker-compose up -d 启动 docker-compose restart 重启
查看容器
[root@docker compose_lnmp]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f8c18829cabf nginx "/docker-entrypoint.…"11 seconds ago Up 9 seconds 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp nginx 72176d819d74 compose_lnmp_php "docker-php-entrypoi…"3 minutes ago Up 3 minutes 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp php ed1f8854128f mysql "docker-entrypoint.s…"3 minutes ago Up 3 minutes 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql
数据化持久目录
[root@docker compose_lnmp]# docker volume ls DRIVER VOLUME NAME local 03c7770fea6d9350f979847be29f2b8146303fbd48116618616628b3b77221a0 local 4e5fed374feab2035464fad478c611db71aa6e1174065fe31b8c4626c7c08ca7 local 7fc541df71d8c55675f12ecf92e219b3f2353b54533a10701443bb3fa17b6d71 local 8c79a13f19fe88e0ece1013cc5bc28bca0433bda2d61c3e67dac4b6f5f61bff8 local 9cc1ed86d97c0dc679e8bc41ec7c4b0d96ced9562b64e42c3583b1d2e854bafc local 16fe9d63e0550065f430ac23bfebc44d90eec5905c7e4c30761aaa8372d146c8 local 401f58ed1ca49d98ad53ac052adda6865a32e3ba82135c869a490d469b6d6f6f local 1397ed5ef8e78fb5fc52b8ffb4c4dce37ed809e8baedacccec43af05f7e5cd5b local 75855c7759d263a7bd9b6ef1ecf5481e828c46d083e55eba199ebb780da57bfd local 907641a94d3a3c4d83e4978a43d9f64575cd4457dfb2b9cf9374556002084f48 local 9872933f652693474acdb9d723376abe90b429801aa6ce1e398face00b1e708d local a2e26dc94e5e02c4c69789c95a75d8d3d5f26fc7d206701ac9606620797949db local compose_lnmp_mysql-config #数据库配置文件 local compose_lnmp_mysql-data #数据库数据文件 local compose_lnmp_mysql-log #数据库日志 local compose_lnmp_nginx-config #nginx配置文件 local compose_lnmp_nginx-html #nginx web目录 local compose_lnmp_nginx-log #nginx日志目录 local compose_lnmp_php-config #php配置文件 local e7d2f4821be653b47497c2670e1d33b691ace4c39f279057efda3ae91a3d21c0
配置php
#默认的php.ini文件是没有的,需要手动把模板配置文件复制为php.ini [root@docker ~]# cd /var/lib/docker/volumes/compose_lnmp_php-config/_data/php [root@docker php]# cp php.ini-production php.ini修改php.ini时区 [root@docker php]# vim php.in date.timezone = Asia/Shanghai
[root@docker ~]# docker container exec -it mysql bash root@mysql:/# mysql -uroot -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.26 MySQL Community Server - GPLCopyright (c)2000, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.mysql>select version(); +-----------+ | version()| +-----------+ |8.0.26 | +-----------+ 1 row inset(0.01 sec)mysql>
验证php
[root&#64;docker ~]# vim /var/lib/docker/volumes/compose_lnmp_nginx-html/_data/index.php <?php phpinfo();