opencart挂载源码目录问题记录
- 准备工作
1. 将已经部署好的opencart的源码目录复制出来/opt/bitnami/opencart
tar cvf opencart.tar.gz opencart
docker cp opencart:/opt/bitnami/opencart.tar.gz ./
2. 解压到目录home/market/opencart
tar xvf opencart.tar.gz
- 添加挂载目录:-v /home/market/opencart:/opt/bitnami/opencart
docker run -it --name opencart -p 81:80 -p 444:443 \
-e MARIADB_HOST=172.31.70.216 \
-e ALLOW_EMPTY_PASSWORD=yes \
-e MARIADB_ROOT_USER=root \
-e MARIADB_ROOT_PASSWORD=xxxxx\
-e OPENCART_DATABASE_NAME=opencart_kee \
-e OPENCART_DATABASE_USER=market_opencart \
-e OPENCART_DATABASE_PASSWORD=xxxxxxxxxxxxx\
-e MYSQL_CLIENT_CREATE_DATABASE_NAME=opencart_kee \
-e MYSQL_CLIENT_CREATE_DATABASE_USER=market_opencart \
-e MYSQL_CLIENT_CREATE_DATABASE_PASSWORD=xxxxxxxxxxxxx\
-v /home/market/data_kee:/bitnami \
-v /home/market/opencart:/opt/bitnami/opencart \
bitnami/opencart:latest
- 运行日志
[root@efmarket opencart]# docker run -it --name opencart_kee -p 81:80 -p 444:443 -e MARIADB_HOST=172.31.70.216 -e ALLOW_EMPTY_PASSWORD=yes -e MARIADB_ROOT_USER=root -e MARIADB_ROOT_PASSWORD=xxxxx -e OPENCART_DATABASE_NAME=opencart_kee -e OPENCART_DATABASE_USER=market_opencart -e OPENCART_DATABASE_PASSWORD=xxxxxxxxxxxxx-e MYSQL_CLIENT_CREATE_DATABASE_NAME=opencart_kee -e MYSQL_CLIENT_CREATE_DATABASE_USER=market_opencart -e MYSQL_CLIENT_CREATE_DATABASE_PASSWORD=xxxxxxxxxxxxx-v /home/market/data_kee:/bitnami -v /home/market/opencart:/opt/bitnami/opencart bitnami/opencart:latest
Welcome to the Bitnami opencart container
Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-opencart
Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-opencart/issues
WARN ==> You set the environment variable ALLOW_EMPTY_PASSWORD=yes. For safety reasons, do not use this flag in a production environment.
nami INFO Initializing apache
apache INFO ==> Patching httpoxy...
apache INFO ==> Configuring dummy certificates...
nami INFO apache successfully initialized
nami INFO Initializing php
nami INFO php successfully initialized
nami INFO Initializing mysql-client
mysql-c INFO Trying to connect to MySQL server
mysql-c INFO Found MySQL server listening at 172.31.70.216:3306
mysql-c INFO MySQL server listening and working at 172.31.70.216:3306
mysql-c INFO ==> Creating database opencart_kee...
mysql-c INFO ==> Granting access to market_opencart to the database opencart_kee...
mysql-c INFO
mysql-c INFO ########################################################################
mysql-c INFO Installation parameters for mysql-client:
mysql-c INFO Database User created: market_opencart
mysql-c INFO Database Name created: opencart_kee
mysql-c INFO Database Password created: **********
mysql-c INFO Database Host: 172.31.70.216
mysql-c INFO Database Port: 3306
mysql-c INFO Database Root User: root
mysql-c INFO Database Root Password: **********
mysql-c INFO (Passwords are not shown for security reasons)
mysql-c INFO ########################################################################
mysql-c INFO
nami INFO mysql-client successfully initialized
nami INFO Initializing libphp
nami INFO libphp successfully initialized
nami INFO Initializing opencart
mysql-c INFO Trying to connect to MySQL server
mysql-c INFO Found MySQL server listening at 172.31.70.216:3306
mysql-c INFO MySQL server listening and working at 172.31.70.216:3306
opencar INFO Preparing webserver environment...
opencar INFO Preparing PHP environment...
Error executing 'postInstallation': Path '/bitnami/opencart/config.php' does not exists
问题分析:配置文件是启动容器时生成的,直接挂载源码导致生成不了,找不到配置
解决方案:
- 不挂载源码目录,启动一次容器
- 将源码复制出来,挂载源码目录;再启动新容器,使用第一次启动的配置目录。