我试图创建多个容器与我现有的Magento项目。
任务#1)我已经成功地将现有的项目移动到Docker通过下面的markshust/docker-magento。一切都工作得很好,正如预期的那样。但这只是为了移动一个Magento示例到Docker
任务#2)我尝试在Docker上创建相同现有Magento项目的多个示例
我尝试用不同的--project-name
创建2个不同的YML(以区分容器)。遵循与任务#1相同的步骤,并更新第二个YML中的外部端口。但不幸的是,我现在无法运行任何容器。没有工作!
当我试图访问第一个Magento容器,例如https://example.com:444/它添加错误在system.log
和奇怪的是,相同的错误被记录在我的第二个Docker容器的system.log
内
我怀疑卷在我的情况下产生了问题(因为卷路径在两个YML中是相同的),但我不能在这里找出确切的问题。添加下面两个YML
docker-compose.yml(放置在docker根目录下)
version: "3"
services:
app:
image: markoshust/magento-nginx:1.18-5
ports:
- "81:8000"
- "444:8443"
depends_on:
- "db"
volumes: &appvolumes
- ~/.composer:/var/www/.composer:cached
- ~/.ssh/id_rsa:/var/www/.ssh/id_rsa:cached
- ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached
- appdata:/var/www/html
- sockdata:/sock
- ssldata:/etc/nginx/certs
networks:
- customNetwork
phpfpm:
image: markoshust/magento-php:7.4-fpm-11
volumes: *appvolumes
env_file: env/phpfpm.env
networks:
- customNetwork
db:
image: mariadb:10.4
restart: on-failure
command: --max_allowed_packet=256M
ports:
- "3307:3306"
env_file: env/db.env
volumes:
- dbdata:/var/lib/mysql
networks:
- customNetwork
redis:
image: redis:5.0-alpine
ports:
- "6379:6379"
networks:
- customNetwork
elasticsearch:
image: markoshust/magento-elasticsearch:7.9.3-1
ports:
- "9201:9200"
- "9301:9300"
environment:
- "discovery.type=single-node"
## Set custom heap size to avoid memory errors
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
## Avoid test failures due to small disks
## More info at https://github.com/markshust/docker-magento/issues/488
- "cluster.routing.allocation.disk.threshold_enabled=false"
- "index.blocks.read_only_allow_delete"
networks:
- customNetwork
volumes:
appdata:
dbdata:
sockdata:
ssldata:
networks:
customNetwork:
docker-compose-second.yml(放置在docker根目录下)
version: "3"
services:
app:
image: markoshust/magento-nginx:1.18-5
ports:
- "82:8000"
- "445:8443"
depends_on:
- "db"
volumes: &appvolumes
- ~/.composer:/var/www/.composer:cached
- ~/.ssh/id_rsa:/var/www/.ssh/id_rsa:cached
- ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached
- appdata:/var/www/html
- sockdata:/sock
- ssldata:/etc/nginx/certs
networks:
- customNetworkM2
phpfpm:
image: markoshust/magento-php:7.4-fpm-11
volumes: *appvolumes
env_file: env/phpfpm.env
networks:
- customNetworkM2
db:
image: mariadb:10.4
restart: on-failure
command: --max_allowed_packet=256M
ports:
- "3308:3306"
env_file: env/db.env
networks:
- customNetworkM2
redis:
image: redis:5.0-alpine
ports:
- "6381:6379"
networks:
- customNetworkM2
elasticsearch:
image: markoshust/magento-elasticsearch:7.9.3-1
ports:
- "9202:9200"
- "9302:9300"
environment:
- "discovery.type=single-node"
## Set custom heap size to avoid memory errors
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
## Avoid test failures due to small disks
## More info at https://github.com/markshust/docker-magento/issues/488
- "cluster.routing.allocation.disk.threshold_enabled=false"
- "index.blocks.read_only_allow_delete"
networks:
- customNetworkM2
volumes:
appdata:
dbdata:
rabbitmqdata:
sockdata:
ssldata:
networks:
customNetworkM2:
db.env(放置在[docker根目录]/env目录中)
MYSQL_HOST=db
MYSQL_ROOT_PASSWORD=magento
MYSQL_DATABASE=magento
MYSQL_USER=root
MYSQL_PASSWORD=magento
MYSQL_INTEGRATION_ROOT_PASSWORD=magento
MYSQL_INTEGRATION_DATABASE=magento_integration_tests
MYSQL_INTEGRATION_USER=root
MYSQL_INTEGRATION_PASSWORD=magento
MYSQL_INTEGRATION_HOST=db
我是新来的Docker。需要一些帮助!P.S.我正在使用Docker & Docker-compose在Ubuntu 18.04和Magento 2.4.3-P1上
1条答案
按热度按时间euoag5mw1#
我认为看一些容易理解的例子可以给予你最好的印象。
你想做的是完全有效的,一个映像应该是你需要运行的任何东西,而不需要配置。
要生成配置,您可以:
a)卷装载
在容器启动docker运行期间使用卷并挂载文件-v my. ini:/etc/mysql/my.ini percona(与docker-compose类似)
B)基于入口点的配置(生成)
c)衍生图像
可能是为了“完整性”,即映像派生策略,因此您有一个名为“myapp”的基础映像,而对于安装X,您创建了一个新映像
从我的应用程序
复制我的. ini/等/我的ql/my.ini
复制应用程序.yml /var/app/config/应用程序.yml