@Chiang
2021-06-26T17:32:33.000000Z
字数 2547
阅读 882
dnmp lnmpa 2021-06
- MacBook Pro
- Win10 专业版
- 关闭防火墙
win+r输入cmd- 进入命令行窗口输入
powershell- 这样常规的
bashshell命令都可以使用了
- 不会污染宿主环境
- 可移植,便于打包
- 启停方便,搭配自如
# 获取镜像docker pull ubuntu:18.04# 查看所有镜像docker image ls -a# 删除镜像docker image rm centos# 删除所有镜像docker rmi `docker image -q`# 根据镜像生成启动容器并进入docker run -it --rm ubuntu:18.04 bash# 查看所有容器docker container ls -a# 启动已存在的容器docker container start web# 终止容器docker container stop web# 进入容器docker exec -it web bash# 删除容器docker container rm web# 清理所有处于终止状态的容器docker container prune# 将容器快照导出到本地文件docker export web > ubuntu.tar# 将容器快照文件导入为镜像cat ubuntu.tar | docker import - fazhan/ubuntu:v1.0# 挂载一个主机目录作为数据卷docker run -it -p 127.0.0.1:8080:80 --name web --mount type=bind,source=C:\Users\admin\dockerdir,target=/root/hostdir ubuntu# 绑定多个端口docker run -it \-p \127.0.0.1:80:80 \127.0.0.1:443:443 \127.0.0.1:3306:3306 \127.0.0.1:6379:6379 \--name web \--mount type=bind,source=C:\Users\admin\dockerdir,target=/root/hostdir \ubuntu
# 创建docker run -it -p 127.0.0.1:8080:80 --name web --mount type=bind,source=C:\Users\admin\dockerdir,target=/root/hostdir ubuntu# 启动docker container start web# 执行&进入docker exec -it web bash# 导出docker export 7691a814370e > ubuntu.tar# 导入cat ubuntu.tar | docker import - fazhan/ubuntu:v1.0# 创建&启动docker run -it fazhan/ubuntu:v1.0 bash# 进入容器内的操作cd ~/hostdirapt-get updateapt-get install screenapt-get install wget# 这里给docker分配的内存要大点,我执行了两次都卡在88%不动了wget http://soft.vpser.net/lnmp/lnmp1.8.tar.gz -cO lnmp1.8.tar.gz && tar zxf lnmp1.8.tar.gz && cd lnmp1.8 && ./install.sh lnmpcd tools# 删掉禁用函数(Laravel依赖)./remove_disable_function.sh# 跨目录移除工具(Laravel依赖)./remove_open_basedir_restriction.sh# 通过Composer安装Laravelcomposer create-project laravel/laravel example-appcd example-app# 这里默认绑定的是8000端口php artisan serve# 关闭 Nginx的80端口占用/etc/init.d/nginx# 绑定80端口php artisan serve --port=80# 或者配置lnmp服务器/usr/local/nginx/conf/nginx.conf# 配置代码server {listen 80;server_name example.com;root /srv/example.com/public;add_header X-Frame-Options "SAMEORIGIN";add_header X-Content-Type-Options "nosniff";index index.php;charset utf-8;location / {try_files $uri $uri/ /index.php?$query_string;}location = /favicon.ico { access_log off; log_not_found off; }location = /robots.txt { access_log off; log_not_found off; }error_page 404 /index.php;location ~ \.php$ {fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;include fastcgi_params;}location ~ /\.(?!well-known).* {deny all;}}
参考:https://github.com/yeszao/dnmp
参考资料:
https://github.com/yeasy/docker_practice
https://github.com/yeszao/dnmp
https://github.com/licess/lnmp
