2.常用命令 #启动并后台运行所有的服务 docker-compose up -d #列出项目中目前的所有容器 docker-compose ps #停止某个服务 docker-compose stop 服务名 #启动某个服务 docker-compose start 服务名 #停止并删除容器、网络、卷、镜像 docker-compose down
3.准备镜像与配置文件 docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 605c77e624dd 2 years ago 141MB mysql 5.6 dd3b2a5dcb48 2 years ago 303MB php 7.3.29-fpm 4c013e5980cf 2 years ago 453MB
nginx配置文件 mkdir /root/lnmp/nginx/conf -p server { listen 80; root /usr/share/nginx/html; index index.html index.htm index.php; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; }
--------------------------------------------------------------- 4.启动docker-compose docker-compose up -d docker-compose ps Name Command State Ports --------------------------------------------------------------------------------------------------- container_nginx /docker-entrypoint.sh ngin ... Up 0.0.0.0:80->80/tcp,:::80->80/tcp mysql6 docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp,:::3306->3306/tcp php73 docker-php-entrypoint php-fpm Up 9000/tcp