摘要:代碼托管準(zhǔn)備工作先安裝好軟件刪除所有容器和鏡像代碼克隆在上到自己的庫(kù)中導(dǎo)入到碼云中還是碼云上快看下有哪些文件
docker-nginx-php-mysql代碼托管
準(zhǔn)備工作先安裝好軟件: git, ????docker,????docker-compose
刪除所有容器和鏡像
$ docker stop $(docker ps -q) && docker rm $(docker ps -aq) $ docker rmi $(docker images -q)01:代碼克隆
在github上fork到自己的庫(kù)中
導(dǎo)入到碼云中
//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 // 使用默認(rèn)的驅(qū)動(dòng)創(chuàng)建網(wǎng)絡(luò) Creating network "docker-nginx-php-mysql_default" with the default driver //服務(wù) 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 //服務(wù) 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 //服務(wù) 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 //服務(wù) 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 ////服務(wù) 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個(gè)容器的名字,mysql和phpmyadmin是在docker-compose.yml中使用container_name:指定的名字,另外三個(gè)是自動(dòng)生成的,都是xxx_服務(wù)名_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 先來(lái)分析下5個(gè)服務(wù)web,php,composer,myadmin,mysqldb,從depends_on來(lái)看,web依賴于php和mysqldb,myadmin依賴于mysqld 那么現(xiàn)在順序應(yīng)該是php,composer,mysqldb,web,myadmin,但實(shí)際上是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 有關(guān)<和>的用法參考: https://blog.csdn.net/zh515858237/article/details/79218176 容器完整id(64位): afbe19d5a2a996b6ef5d64afb0087d9df151eea6f67604d059c943d63008a970 截取顯示(12位): afbe19d5a2a9down
vagrant@qianjin:~/docker-nginx-php-mysql$ sudo docker-compose down測(cè)試
http://192.168.10.10:8080 (vagrant工作環(huán)境)正常
http://127.0.0.1
http://192.168.10.10:8000/ 有錯(cuò)誤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,得進(jìn)入容器進(jìn)行修改
分析docker-compose.yaml
services: web: volumes: - "./web:/var/www/html"
宿主機(jī)的web目映射到容器的/var/www/html,進(jìn)入容器
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 // 修改宿主機(jī)中的 vagrant@qianjin:~/docker-nginx-php-mysql/web/public$ sudo vim index.php //index.php的內(nèi)容改為如下,現(xiàn)在okDocker getName(); ?> Docker getName(); ?>
https://github.com/yeszao/dnmp
使用記錄,這個(gè)up的時(shí)間比較長(zhǎng),約8分30秒
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/40110.html
摘要:代碼托管準(zhǔn)備工作先安裝好軟件刪除所有容器和鏡像代碼克隆在上到自己的庫(kù)中導(dǎo)入到碼云中還是碼云上快看下有哪些文件 docker-nginx-php-mysql代碼托管 準(zhǔn)備工作 先安裝好軟件: git, ????docker,????docker-compose 刪除所有容器和鏡像 $ docker stop $(docker ps -q) && docker rm $(docker p...
摘要:代碼托管準(zhǔn)備工作先安裝好軟件刪除所有容器和鏡像代碼克隆在上到自己的庫(kù)中導(dǎo)入到碼云中還是碼云上快看下有哪些文件 docker-nginx-php-mysql代碼托管 準(zhǔn)備工作 先安裝好軟件: git, ????docker,????docker-compose 刪除所有容器和鏡像 $ docker stop $(docker ps -q) && docker rm $(docker p...
摘要:使用筆記寫在前面最近用上了來(lái)搭建環(huán)境和開發(fā)一個(gè)的項(xiàng)目,也順帶學(xué)習(xí)使用。關(guān)于的學(xué)習(xí),請(qǐng)移步官方文檔數(shù)據(jù)庫(kù)連接的問題今天踩了一個(gè)數(shù)據(jù)庫(kù)連接的坑,記錄之。 laradock 使用筆記 寫在前面 最近用上了laradock來(lái)搭建環(huán)境和開發(fā)一個(gè)laravel5.5的項(xiàng)目,也順帶學(xué)習(xí)使用docker。 關(guān)于laradock的學(xué)習(xí),請(qǐng)移步官方文檔 mysql數(shù)據(jù)庫(kù)連接的問題 今天踩了一個(gè)數(shù)據(jù)庫(kù)連接的...
閱讀 2212·2021-11-22 13:52
閱讀 3847·2021-11-10 11:36
閱讀 1380·2021-09-24 09:47
閱讀 1088·2019-08-29 13:54
閱讀 3360·2019-08-29 13:46
閱讀 1942·2019-08-29 12:16
閱讀 2108·2019-08-26 13:26
閱讀 3471·2019-08-23 17:10