全栈工程师-咨询电话:15675178605 (微信同号)

挂载宿主机目录到各系统Docker容器中_Docker容器化部署

一、挂载宿主机的目录到各项目Docker容器中,实现项目数据与宿主目录同步。

1、删除之前创建运行的所有项目容器

运行命令:【 docker rm -f $(docker ps -aq) 】 这个是删除所有容器
运行命令:【 docker ps -a 】查看容器是否删除成功。

2、重新创建运行各项目docker容器,并挂载相应的主机的目录

docker run -e "TZ=Asia/Shanghai" -d -p 9004:80 --name octadvertisersystemweb_publish_con -v /OctMallAllWeb/OctAdvertiserSystemWeb:/octshop/OctAdvertiserSystemWeb registry.cn-hangzhou.aliyuncs.com/octshop/octadvertisersystemweb_publish_mirr:v3

docker run -e "TZ=Asia/Shanghai" -d -p 9005:80 --name octaftersaleacccussystemweb_publish_con -v /OctMallAllWeb/OctAfterSaleAccCusSystemWeb:/octshop/OctAfterSaleAccCusSystemWeb registry.cn-hangzhou.aliyuncs.com/octshop/octaftersaleacccussystemweb_publish_mirr:v3

docker run -e "TZ=Asia/Shanghai" -d -p 9009:80 --name octcmssystemweb_publish_con -v /OctMallAllWeb/OctCmsSystemWeb:/octshop/OctCmsSystemWeb registry.cn-hangzhou.aliyuncs.com/octshop/octcmssystemweb_publish_mirr:v3

docker run -e "TZ=Asia/Shanghai" -d -p 9000:80 --name octcommoncodesystemweb_publish_con -v /OctMallAllWeb/OctCommonCodeSystemWeb:/octshop/OctCommonCodeSystemWeb registry.cn-hangzhou.aliyuncs.com/octshop/octcommoncodesystemweb_publish_mirr:v3

docker run -e "TZ=Asia/Shanghai" -d -p 9006:80 --name octfileuploadsystemweb_publish_con -v /OctMallAllWeb/OctFileUploadSystemWeb:/octshop/OctFileUploadSystemWeb registry.cn-hangzhou.aliyuncs.com/octshop/octfileuploadsystemweb_publish_mirr:v3

docker run -e "TZ=Asia/Shanghai" -d -p 9011:80 --name octmallappweb_publish_con -v /OctMallAllWeb/OctMallAppWeb:/octshop/OctMallAppWeb registry.cn-hangzhou.aliyuncs.com/octshop/octmallappweb_publish_mirr:v3

docker run -e "TZ=Asia/Shanghai" -d -p 9010:80 --name octmallminiweb_publish_con -v /OctMallAllWeb/OctMallMiniWeb:/octshop/OctMallMiniWeb registry.cn-hangzhou.aliyuncs.com/octshop/octmallminiweb_publish_mirr:v3

docker run -e "TZ=Asia/Shanghai" -d -p 9008:80 --name octshopsystemweb_publish_con -v /OctMallAllWeb/OctShopSystemWeb:/octshop/OctShopSystemWeb registry.cn-hangzhou.aliyuncs.com/octshop/octshopsystemweb_publish_mirr:v3

docker run -e "TZ=Asia/Shanghai" -d -p 9003:80 --name octthirdapicallsystemweb_publish_con -v /OctMallAllWeb/OctThirdApiCallSystemWeb:/octshop/OctThirdApiCallSystemWeb registry.cn-hangzhou.aliyuncs.com/octshop/octthirdapicallsystemweb_publish_mirr:v3

docker run -e "TZ=Asia/Shanghai" -d -p 9002:80 --name octtradingsystemweb_publish_con -v /OctMallAllWeb/OctTradingSystemWeb:/octshop/OctTradingSystemWeb registry.cn-hangzhou.aliyuncs.com/octshop/octtradingsystemweb_publish_mirr:v3

docker run -e "TZ=Asia/Shanghai" -d -p 9001:80 --name octusergoodsshopsystemweb_publish_con -v /OctMallAllWeb/OctUserGoodsShopSystemWeb:/octshop/OctUserGoodsShopSystemWeb registry.cn-hangzhou.aliyuncs.com/octshop/octusergoodsshopsystemweb_publish_mirr:v3

docker run -e "TZ=Asia/Shanghai" -d -p 9007:80 --name octwapweb_publish_con -v /OctMallAllWeb/OctWapWeb:/octshop/OctWapWeb registry.cn-hangzhou.aliyuncs.com/octshop/octwapweb_publish_mirr:v3

3、查看新建的Docker容器,是否运行正常。

运行命令 【 docker ps -a 】 如下图:



二、设置各项目Docker容器,开机自动启动,依次运行下面的命令

docker update --restart=always octadvertisersystemweb_publish_con

docker update --restart=always octaftersaleacccussystemweb_publish_con

docker update --restart=always octcmssystemweb_publish_con

docker update --restart=always octcommoncodesystemweb_publish_con

docker update --restart=always octfileuploadsystemweb_publish_con

docker update --restart=always octmallappweb_publish_con

docker update --restart=always octmallminiweb_publish_con

docker update --restart=always octshopsystemweb_publish_con

docker update --restart=always octthirdapicallsystemweb_publish_con

docker update --restart=always octtradingsystemweb_publish_con

docker update --restart=always octusergoodsshopsystemweb_publish_con

docker update --restart=always octwapweb_publish_con


上一步:创建与运行商城各大系统Docker容器_Docker容器化部署

下一步:创建运行Nginx容器和修改配置_Docker容器化部署