摘要:代码托管准备工作先安装好软件删除所有容器和镜像代码克隆在上到自己的库中导入到码云中还是码云上快看下有哪些文件
docker-nginx-php-mysql代码托管
准备工作先安装好软件: git, docker, docker-compose
删除所有容器和镜像
$ docker stop $(docker ps -q) && docker rm $(docker ps -aq) $ docker rmi $(docker images -q)01:代码克隆
在github上fork到自己的库中
导入到码云中
//vagrant@qianjin:~$ git clone https://github.com/nanoninja/docker-nginx-php-mysql.git // 还是码云上快 $ abcd@bogon:/var/www/qianjin$ git clone https://gitee.com/advance/docker-nginx-php-mysql.git && sudo mv docker-nginx-php-mysql/ 20180930/ // 看下有哪些文件 //vagrant@qianjin:~$ cd docker-nginx-php-mysql //vagrant@qianjin:~/docker-nginx-php-mysql$ tree abcd@bogon:/var/www/qianjin$ cd 20180930 && tree . ├── doc │ ├── configure-cacert-for-local-macosx.md │ ├── images │ │ ├── cacert-1-warning.png │ │ ├── cacert-2-open-keychain.png │ │ ├── cacert-3-add-cacert-file-import.png │ │ ├── cacert-4-locate-cert.png │ │ ├── cacert-5-set-to-always-trust.png │ │ ├── cacert-6-reload-page.png │ │ ├── ps-mac-php-cli-add-interpreter.png │ │ ├── ps-mac-php-interpreter.png │ │ ├── ps-mac-php-phpunit-config.png │ │ ├── ps-mac-php-phpunit-demo.png │ │ ├── ps-mac-php-phpunit.png │ │ ├── ps-mac-php-xdebug-demo.png │ │ ├── ps-mac-php-xdebug.png │ │ ├── ps-mac-php-xdebug-proxy.png │ │ └── ps-mac-php-xdebug-server.png │ └── phpstorm-macosx.md ├── docker-compose.yml ├── etc │ ├── nginx │ │ ├── default.conf │ │ └── default.template.conf │ └── php │ └── php.ini ├── Makefile ├── README.md └── web ├── app │ ├── composer.json.dist │ ├── phpunit.xml.dist │ ├── src │ │ └── Foo.php │ └── test │ ├── bootstrap.php │ └── FooTest.php └── public └── index.php代码修改
.env中
代码拷贝处理vagrant@qianjin:~/docker-nginx-php-mysql$ cp web/app/composer.json.dist web/app/composer.json
upvagrant@qianjin:~/docker-nginx-php-mysql$ sudo docker-compose up -d
up过程记录
vagrant@qianjin:~/docker-nginx-php-mysql$ sudo docker-compose up -d // 使用默认的驱动创建网络 Creating network "docker-nginx-php-mysql_default" with the default driver //服务 php Pulling php (nanoninja/php-fpm:latest)... latest: Pulling from nanoninja/php-fpm e7bb522d92ff: Pull complete 75651f247827: Pull complete dbcf8fd0150f: Pull complete de80263f26f0: Pull complete 4cbd879bcaec: Pull complete 5d2b7aa2544b: Pull complete 59faa2f7b345: Pull complete 1a363d08f38a: Pull complete 544057eb652d: Pull complete 8bb691f94a43: Pull complete e2eb2ce681bb: Pull complete Digest: sha256:e9bc64908e5324e361fb875025111adbd5ba668cff0a8476b5e541177bc25889 Status: Downloaded newer image for nanoninja/php-fpm:latest //服务 composer Pulling composer (composer:)... latest: Pulling from library/composer c67f3896b22c: Pull complete 88777455d910: Pull complete 955e2028dd61: Pull complete 7d47ce93cc1f: Pull complete db3780f51b99: Pull complete 28db5a4e528c: Pull complete 1ea3e552f254: Pull complete 280d419dafce: Pull complete 9d23cdaa3043: Pull complete 6de5c1e960b6: Pull complete c4421176aec0: Pull complete 78a2d4d305a7: Pull complete 290c319347c7: Pull complete 51a9f3b40d22: Pull complete 5ca8f0d296e8: Pull complete Digest: sha256:31c3d9c8ae82992c1cd724c9812e057d2a8c8c6b49b86d5f1021060bc96ea004 Status: Downloaded newer image for composer:latest //服务 mysqldb Pulling mysqldb (mysql:5.7.22)... 5.7.22: Pulling from library/mysql be8881be8156: Pull complete c3995dabd1d7: Pull complete 9931fdda3586: Pull complete bb1b6b6eff6a: Pull complete a65f125fa718: Pull complete 2d9f8dd09be2: Pull complete 37b912cb2afe: Pull complete 79592d21cb7f: Pull complete 00bfe968d82d: Pull complete 79cf546d4770: Pull complete 2b3c2e6bacee: Pull complete Digest: sha256:aaba540cdd9313645d892f4f20573e8b42b30e5be71c054b7befed2f7da5f85b Status: Downloaded newer image for mysql:5.7.22 //服务 myadmin Pulling myadmin (phpmyadmin/phpmyadmin:)... latest: Pulling from phpmyadmin/phpmyadmin 911c6d0c7995: Pull complete 2527cc05836d: Pull complete 3299172a2d6d: Pull complete 05782106624f: Pull complete 3e3261543ec8: Pull complete ce1c845d4246: Pull complete e005e70f55dc: Pull complete 84403a106e16: Pull complete e4fc13f7949f: Pull complete 2a53e72ea7b9: Pull complete d791f6b71f27: Pull complete 576bdfd7cc75: Pull complete 20768032f0fb: Pull complete fc8aa3d46064: Pull complete bade7affffd704: Pull complete 4b30a4dd0b24: Pull complete b02d6e91d2b5: Pull complete Digest: sha256:6fa491d4e3994ab3ec3410409bf0d59436072df1cfb16b8fe25c47486988103f Status: Downloaded newer image for phpmyadmin/phpmyadmin:latest ////服务 web Pulling web (nginx:alpine)... alpine: Pulling from library/nginx c67f3896b22c: Already exists 89df19b7dc5c: Pull complete c34d3c110d67: Pull complete 9ac8b8076c62: Pull complete Digest: sha256:829a63ad2b1389e393e5decf5df25860347d09643c335d1dc3d91d25326d3067 Status: Downloaded newer image for nginx:alpine // 5个容器的名字,mysql和phpmyadmin是在docker-compose.yml中使用container_name:指定的名字,另外三个是自动生成的,都是xxx_服务名_1 Creating docker-nginx-php-mysql_php_1 ... done Creating docker-nginx-php-mysql_composer_1 ... done Creating mysql ... done Creating phpmyadmin ... done Creating docker-nginx-php-mysql_web_1 ... done 先来分析下5个服务web,php,composer,myadmin,mysqldb,从depends_on来看,web依赖于php和mysqldb,myadmin依赖于mysqld 那么现在顺序应该是php,composer,mysqldb,web,myadmin,但实际上是web在最后 afbe19d5a2a9 nginx:alpine "/bin/sh -c "envsubst "$NGINX_HOST" < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g "daemon off;""" 16 minutes ago Up 16 minutes 0.0.0.0:8000->80/tcp, 0.0.0.0:3000->443/tcp docker-nginx-php-mysql_web_1 c3fce36d9225 phpmyadmin/phpmyadmin "/run.sh supervisord -n" 16 minutes ago Up 16 minutes 9000/tcp, 0.0.0.0:8080->80/tcp phpmyadmin 0251b4e667d2 nanoninja/php-fpm:latest "docker-php-entrypoint php-fpm" 16 minutes ago Up 16 minutes 9000/tcp docker-nginx-php-mysql_php_1 dbce5f6af8fc composer "/bin/sh /docker-entrypoint.sh install" 16 minutes ago Up 16 minutes docker-nginx-php-mysql_composer_1 7c0f691cbb04 mysql:5.7.22 "docker-entrypoint.sh mysqld" 16 minutes ago Up 16 minutes 0.0.0.0:8989->3306/tcp mysql 有关<和>的用法参考: https://blog.csdn.net/zh515858237/article/details/79218176 容器完整id(64位): afbe19d5a2a996b6ef5d64afb0087d9df151eea6f67604d059c943d63008a970 截取显示(12位): afbe19d5a2a9down
vagrant@qianjin:~/docker-nginx-php-mysql$ sudo docker-compose down测试
http://192.168.10.10:8080 (vagrant工作环境)正常
http://127.0.0.1
http://192.168.10.10:8000/ 有错误Warning: include(../app/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/public/index.php on line 3,得进入容器进行修改
分析docker-compose.yaml
services: web: volumes: - "./web:/var/www/html"
宿主机的web目映射到容器的/var/www/html,进入容器
vagrant@qianjin:~/docker-nginx-php-mysql$ docker exec -it afbe19d5a2a9 /bin/sh ~ # cd /var/www/html/app /var/www/html/app # ls composer.json composer.json.dist composer.lock phpunit.xml.dist src test vendor // 修改宿主机中的 vagrant@qianjin:~/docker-nginx-php-mysql/web/public$ sudo vim index.php //index.php的内容改为如下,现在okDocker getName(); ?> Docker getName(); ?>
https://github.com/yeszao/dnmp
使用记录,这个up的时间比较长,约8分30秒
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/27468.html
摘要:代码托管准备工作先安装好软件删除所有容器和镜像代码克隆在上到自己的库中导入到码云中还是码云上快看下有哪些文件 docker-nginx-php-mysql代码托管 准备工作 先安装好软件: git, docker, docker-compose 删除所有容器和镜像 $ docker stop $(docker ps -q) && docker rm $(docker p...
摘要:代码托管准备工作先安装好软件删除所有容器和镜像代码克隆在上到自己的库中导入到码云中还是码云上快看下有哪些文件 docker-nginx-php-mysql代码托管 准备工作 先安装好软件: git, docker, docker-compose 删除所有容器和镜像 $ docker stop $(docker ps -q) && docker rm $(docker p...
摘要:使用笔记写在前面最近用上了来搭建环境和开发一个的项目,也顺带学习使用。关于的学习,请移步官方文档数据库连接的问题今天踩了一个数据库连接的坑,记录之。 laradock 使用笔记 写在前面 最近用上了laradock来搭建环境和开发一个laravel5.5的项目,也顺带学习使用docker。 关于laradock的学习,请移步官方文档 mysql数据库连接的问题 今天踩了一个数据库连接的...
阅读 1358·2021-11-15 11:45
阅读 3125·2021-09-27 13:36
阅读 2870·2019-08-30 15:54
阅读 987·2019-08-29 12:38
阅读 2907·2019-08-29 11:22
阅读 2986·2019-08-26 13:52
阅读 2031·2019-08-26 13:30
阅读 585·2019-08-26 10:37