Code Monkey home page Code Monkey logo

docker-magento2's Introduction

Docker Magento2: Varnish 7 + PHP 8.2 + Redis 6.2 + Elasticsearch 7.17 + SSL cluster ready docker-compose infrastructure

If you find my work valuable, please consider sponsoring
Sponsor me on GitHub Buy me a coffee Donate via PayPal

Infrastructure overview

  • Container 1: Mysql 8.0
  • Container 2: Redis 7.0 (volatile, for Magento's cache)
  • Container 3: Redis 7.0 (for Magento's sessions)
  • Container 4: Apache 2.4 + PHP 8.2 (modphp)
  • Container 5: Cron
  • Container 6: Varnish 7.1
  • Container 7: Redis (volatile, cluster nodes autodiscovery)
  • Container 8: Nginx SSL terminator
  • Container 9: Elasticsearch 7.17

Why a separate cron container?

First of all containers should be (as far as possible) single process, but the most important thing is that (if someday we'll be able to deploy this infrastructure in production) we may need a cluster of apache+php containers but a single cron container running.

Plus, with this separation, in the context of a docker swarm, you may be able in the future to separare resources allocated to the cron container from the rest of the infrastructure.

Setup Magento 2

Download Magento 2 in any way you want (zip/tgz from website, composer, etc) and extract in the "magento2" subdirectory of this project.

If you want to change the default "magento2" directory simply change its name in the "docker-compose.yml" (there are 2 references, under the "cron" section and under the "apache" section).

Starting all docker containers

docker-compose up -d

The fist time you run this command it's gonna take some time to download all the required images from docker hub.

Install Magento2

Method 1: CLI

docker exec -it docker-magento2-apache-1 bash
php bin/magento setup:install \
  --db-host docker-magento2-db-1 --db-name magento2 --db-user magento2 --db-password magento2  --admin-user admin --timezone 'Europe/Rome' --currency EUR --use-rewrites 1 --cleanup-database \
  --backend-frontname admin --admin-firstname AdminFirstName --admin-lastname AdminLastName --admin-email '[email protected]' --admin-password 'ChangeThisPassword1' --base-url 'https://magento2.docker/' --language en_US \
  --session-save=redis --session-save-redis-host=sessions --session-save-redis-port=6379 --session-save-redis-db=0 --session-save-redis-password='' \
  --cache-backend=redis --cache-backend-redis-server=cache --cache-backend-redis-port=6379 --cache-backend-redis-db=0 \
  --page-cache=redis --page-cache-redis-server=cache --page-cache-redis-port=6379 --page-cache-redis-db=1 \
  --search-engine=elasticsearch7 --elasticsearch-host=elasticsearch

Deploy static files

docker exec -it docker-magento2-apache-1 bash
php bin/magento dev:source-theme:deploy
php bin/magento setup:static-content:deploy

Enable Varnish

Varnish Full Page Cache should already be enabled out of the box (we startup Varnish with the default VCL file generated by Magento2) but you could anyway go to "stores -> configuration -> advanced -> system -> full page cache" and:

  • select Varnish in the "caching application" combobox
  • type "apache" in both "access list" and "backend host" fields
  • type 80 in the "backend port" field
  • save

Configure Magento to purge Varnish:

docker exec -it docker-magento2_apache_1 bash
php bin/magento setup:config:set --http-cache-hosts=varnish

https://devdocs.magento.com/guides/v2.3/config-guide/varnish/use-varnish-cache.html

Enable SSL Support

Add this line to magento2/.htaccess

SetEnvIf X-Forwarded-Proto https HTTPS=on

Then you can configure Magento as you wish to support secure urls.

If you need to generate new self signed certificates use this command

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt

then you can mount them into the nginx-ssl container using the "volumes" instruction in the docker-compose.xml file. Same thing goes if you need to use custom nginx configurations (you can mount them into /etc/nginx/conf.d). Check the source code of https://github.com/fballiano/docker-nginx-ssl-for-magento2 to better understand where are the configuration stored inside the image/container.

Scaling apache containers

If you need more horsepower you can

docker-compose scale apache=X

where X is the number of apache containers you want.

The cron container will check how many apache containers we have (broadcast/discovery service is stored on the redis_clusterdata container) and will update Varnish's VCL.

You can start your system with just one apache container, then scale it afterward, autodiscovery will reconfigure the load balancing on the fly.

Also, the cron container (which updates Varnish's VCL) sets a "probe" to "/fb_host_probe.txt" every 5 seconds, if 1 fails (container has been shut down) the container is considered sick.

Custom php.ini

We already have a personalized php.ini inside this project: https://github.com/fballiano/docker-magento2-apache-php/blob/master/php.ini but if you want to further customize your settings:

  • edit the php.ini file in the root directoy of this project
  • edit the "docker-compose.xml" file, look for the 2 commented lines (under the "cron" section and under the "apache" section) referencing the php.ini
  • start/restart the docker stack

Please note that your php.ini will be the last parsed thus you can ovverride any setting.

Tested on:

  • Docker for Mac 19

TODO

  • DB clustering?
  • RabbitMQ? let me know what features would you like to see implemented.

Changelog:

  • 2020-09-19:
    • Magento 2.4 branch added
    • Elasticsearch container added for Magento 2.4
    • Upaded all dependencies
  • 2020-03-18:
    • added "sockets" PHP extension to docker-apache-php image
    • fixed some typos/mistakes in the README
    • added CLI install to the README
    • refactored some parts of the documentation to better use magento's CLI
  • 2019-08-09:
    • small bugfix in varnishadm.sh and varnishncsa.sh scripts
  • 2019-08-06:
    • new redis sessions container was added
  • 2019-08-05:
    • migrated to docker-compose syntax 3.7
    • implemented "delegated" consistency for some of volumes for a better performance
    • varnish.vcl was regenerated for Varnish 5 (which was already used since some months)

docker-magento2's People

Contributors

bennythejudge avatar bryant1410 avatar fballiano avatar ilevennet avatar peppelauro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-magento2's Issues

Magento 2.3.2 return error SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13

Warning: Use of undefined constant SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13 - assumed 'SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13' (this will throw an Error in a future version of PHP) in /var/www/html/vendor/magento/framework/Encryption/Encryptor.php on line 153
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento2.core_config_data' doesn't exist in /var/www/html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91 Stack trace: #0 /var/www/html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(91): PDOStatement->execute(Array) #1

Adding module breaks the store

I tried adding a module and after the store is broken. Any page I try to open I get this error:

An error has happened during application run. See exception log for details. Could not write error message to log. Please use developer mode to see the message.

I looked into the apache container, under /var/www/html/var/log, into exception.log and I found this recurring entry:

[2018-02-19 08:27:56] main.CRITICAL: Can't create directory /var/www/html/generated/code/Magento/Framework/App/Http/. in [Magento\Framework\App\Http\Interceptor] {"exception":"[object] (RuntimeException(code: 0): Can't create directory /var/www/html/generated/code/Magento/Framework/App/Http/. in [Magento\\Framework\\App\\Http\\Interceptor] at /var/www/html/vendor/magento/framework/Code/Generator.php:115)"} []
[2018-02-19 08:27:58] main.CRITICAL: Can't create directory /var/www/html/generated/code/Magento/Framework/App/Http/. in [Magento\Framework\App\Http\Interceptor] {"exception":"[object] (RuntimeException(code: 0): Can't create directory /var/www/html/generated/code/Magento/Framework/App/Http/. in [Magento\\Framework\\App\\Http\\Interceptor] at /var/www/html/vendor/magento/framework/Code/Generator.php:115)"} []
[2018-02-19 08:30:47] main.CRITICAL: Can't create directory /var/www/html/generated/code/Magento/Framework/App/Http/. in [Magento\Framework\App\Http\Interceptor] {"exception":"[object] (RuntimeException(code: 0): Can't create directory /var/www/html/generated/code/Magento/Framework/App/Http/. in [Magento\\Framework\\App\\Http\\Interceptor] at /var/www/html/vendor/magento/framework/Code/Generator.php:115)"} []

I installed the module Mageplaza_Smtp by going into the apache container and running the composer:

php composer require mageplaza/module-smtp
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy

I did not change the docker-compose.yml file and I download and untarred magento2 with sample data inside a directory magento2 added at the top of this repo.

Does anyone know what I did wrong or how to fix this problem?

You don't have permission to access / on this server.

Hello.

I tried following the instructions but ended up unable to access the magento store. My current setup is:

/var/local/docker/docker-magento2-master: everything downloaded from this Github project
/var/local/docker/magento2: magento2 downloaded from M2's github project

And that's it. Didn't edited anything. entered folder docker-magento2-master and ran docker-compose up -d. After that, when I try to access http://magento2.docker/ it gives the following error:

Forbidden

You don't have permission to access / on this server.
Apache/2.4.10 (Debian) Server at magento2.docker Port 80

What am I doing wrong?

Scaling does not work

With the default configuration, I am not seeing a load balancing between the apache containers. All load is on apache-1 (with for example 5 different apache containers)

Docker version 24.0.7
Docker-compose version 2.20.0

502 Bad Gateway on certain requests

I've got a pretty much clean install of these 5 or so containers using docker-compose, and have magento2 installed, but every third request or so I'm getting 502 Bad Gateway because of a connection that was reset by apache. This happens occasionally on random requests.

I'm going to enable developer mode and see if I can find any more information. No extensions or code customizations at this point have been implemented.

UPDATE (found this right when it happens):

varnish_1 | Child (17) died signal=6 (core dumped)
varnish_1 | Child (17) Panic message:
varnish_1 | Assert error in vbf_fetch_thread(), cache/cache_fetch.c line 842:
varnish_1 | Condition(uu == bo->fetch_obj->len) not true.
varnish_1 | thread = (cache-worker)
varnish_1 | ident = Linux,4.4.0-71-generic,x86_64,-smalloc,-smalloc,-hcritbit,epoll
varnish_1 | Backtrace:
varnish_1 | 0x4330a8: varnishd() [0x4330a8]
varnish_1 | 0x421025: varnishd() [0x421025]
varnish_1 | 0x435cdc: varnishd(Pool_Work_Thread+0x39c) [0x435cdc]
varnish_1 | 0x44912c: varnishd() [0x44912c]
varnish_1 | 0x7fbe94c200a4: /lib/x86_64-linux-gnu/libpthread.so.0(+0x80a4) [0x7fbe94c200a4]
varnish_1 | 0x7fbe9495587d: /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7fbe9495587d]
varnish_1 | busyobj = 0x7fbe8346c020 {
varnish_1 | ws = 0x7fbe8346c0e0 {
varnish_1 | id = "bo",
varnish_1 | {s,f,r,e} = {0x7fbe8346e008,+864,(nil),+57368},

Here is a varnish ticket addressing the issue.. https://www.varnish-cache.org/trac/ticket/1596

Cron container outdated

I see you're using the following container:

image: fballiano/magento2-cron:M2.4

This one is outdated and is using php 7.4
There is also no 2.4.5 cron docker available (I see you already made a 2.4.5 in github but this one does use your php docker version 2.4)

disk space

Hi,

I usually get the website stuck till weeks working. The problem is the containers get full:

[2017-07-17 12:33:07] main.CRITICAL: SQLSTATE[HY000]: General error: 1021 Disk full (/tmp/#sql_1_0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device"), query was: SELECT main.value_id, main.valueASfile, main.media_type, entity.entity_id, value.label, value.position, value.disabled, default_value.labelASlabel_default, default_value.positionASposition_default, default_value.disabledASdisabled_default, value_video.providerASvideo_provider, value_video.urlASvideo_url, value_video.titleASvideo_title, value_video.descriptionASvideo_description, value_video.metadataASvideo_metadata, default_value_video.prov`

Redis configuration and cache

Hello!
I've enabled redis for magento's cache, with your settings, but here's my problem: my cms content keeps being cached. I've tried with a "redish-cli flushall" on redis container but did not work.
And flushing cache via magento admin didn't work too.

Thanks

DB container name should be same as service name in composer file

In my understanding, the hostname of a container within a compose configuration is the name of the service in the compose file.
db: image: mariadb ports: - "3306:3306" volumes: - dbdata:/var/lib/mysql

Following the README to install Magento2, I found that the hostname suggest dockermagento2_db_1 did not work for me, but db did.

From the Docker doc:

For example, suppose your app is in a directory called myapp, and your docker-compose.yml looks like this:

version: "3" services: web: build: . ports: - "8000:8000" db: image: postgres ports: - "8001:5432"

When you run docker-compose up, the following happens:
A network called myapp_default is created.
A container is created using web’s configuration. It joins the network myapp_default under the name web.
A container is created using db’s configuration. It joins the network myapp_default under the name db.

I am going to submit a PR to this effect.

Use composer

How i use composer through docker container, you can show the command? i want install some modules.

Thank you.

bind source path does not exist

I am trying to configure but getting this error

vagrant_data_db_1 is up-to-date
vagrant_data_cache_1 is up-to-date
vagrant_data_sessions_1 is up-to-date
vagrant_data_clusterdata_1 is up-to-date
Creating vagrant_data_apache_1 ... error

ERROR: for vagrant_data_apache_1 Cannot create container for service apache: invalid mount config for type "bind": bind source path does not exist

ERROR: for apache Cannot create container for service apache: invalid mount config for type "bind": bind source path does not exist
ERROR: Encountered errors while bringing up the project.

Issues when we have a MySql or MariaDb already using port 3306 and a server (Apache or Nginx) using port 80.

I am using as OS Ubuntu 16.04 with a MariaDB using port 3306 and a Nginx using port 80.

With this scenario I've got 2 issues when running docker-compose up -d.

Creating dockermagento2_db_1          ... error
Digest: sha256:723ffc12c182a32d6cadd3782aaa2072625ae4692c58c663875175f11beb044c
Creating dockermagento2_cache_1       ... done
Creating dockermagento2_db_1          ... 
Creating dockermagento2_clusterdata_1 ... done
Creating dockermagento2_cache_1       ... 

ERROR: for dockermagento2_db_1  Cannot start service db: driver failed programming external connectivity on endpoint dockermagento2_db_1 (83e1a7be90858d0fa4636041ad98974cbe06c2002e9e9aea12365d5a06dd2bf7): Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use

ERROR: for db  Cannot start service db: driver failed programming external connectivity on endpoint dockermagento2_db_1 (83e1a7be90858d0fa4636041ad98974cbe06c2002e9e9aea12365d5a06dd2bf7): Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use
ERROR: Encountered errors while bringing up the project.

AND

Creating dockermagento2_cache_1       ... done
Creating dockermagento2_db_1          ... done
Creating dockermagento2_clusterdata_1 ... done
Status: Downloaded newer image for fballiano/magento2-cron:latest
Creating dockermagento2_apache_1      ... done
Creating dockermagento2_clusterdata_1 ... 
Creating dockermagento2_varnish_1     ... error
Creating dockermagento2_apache_1      ... 
Creating dockermagento2_varnish_1     ... 

ERROR: for dockermagento2_varnish_1  Cannot start service varnish: driver failed programming external connectivity on endpoint dockermagento2_varnish_1 (8724c0698332233ac6d91193e4265aebfdafbaaf333797ab2fb67bee12e32790): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use

ERROR: for varnish  Cannot start service varnish: driver failed programming external connectivity on endpoint dockermagento2_varnish_1 (8724c0698332233ac6d91193e4265aebfdafbaaf333797ab2fb67bee12e32790): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use
ERROR: Encountered errors while bringing up the project.

Basically, the port 3306 and 80 were already in use.

I fixed trough the docker-compose.yml.

I just changed

varnish:
    image: fballiano/varnish
    ports:
      - "81:80" #Instead of 80:80
      - "6082:6082"

AND
db:
    image: mariadb
    ports:
      - "33061:3306" ## Instead of 3306:3306

Also open the browser to the addres http://0.0.0.0:81 instead of http://magento2.docker/
It is working.

But I'm getting issue related to database.
How to solve it?
SQLSTATE[HY000] [2002] No such file or directory
dbissue

Installation directory permissions issue

Hi!
During the installation I have an issue, do you have an idea ? I trie to connect to the apache container and give full permissions on generated folder, but the issue persist :
[2019-07-16 23:54:09] main.CRITICAL: The path "/var/www/html/generated/code/Magento/Catalog/Model/ResourceModel/Product/CollectionFactory.php.31" cannot be renamed into "/var/www/html/generated/code/Magento/Catalog/Model/ResourceModel/Product/CollectionFactory.php" Warning!rename(/var/www/html/generated/code/Magento/Catalog/Model/ResourceModel/Product/CollectionFactory.php.31,/var/www/html/generated/code/Magento/Catalog/Model/ResourceModel/Product/CollectionFactory.php): No such file or directory
Class Magento\Catalog\Model\ResourceModel\Product\CollectionFactory generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. [] []

Varnish's VCL cannot be updated

When I go to Cron container and run php updatenodes.php I get the following error:

Fatal error: Uncaught Error: Call to undefined method Mage::getStoreConfig() in /varnish.php:502
Stack trace:
#0 /varnish.php(340): Nexcessnet_Turpentine_Model_Varnish_Admin_Socket->_command('auth', 200, 'REDACTED...')
#1 /varnish.php(267): Nexcessnet_Turpentine_Model_Varnish_Admin_Socket->_connect()
#2 /varnish.php(517): Nexcessnet_Turpentine_Model_Varnish_Admin_Socket->getVersion()
#3 /varnish.php(162): Nexcessnet_Turpentine_Model_Varnish_Admin_Socket->_translateCommandMethod('vcl_list')
#4 /updatenodes.php(21): Nexcessnet_Turpentine_Model_Varnish_Admin_Socket->__call('vcl_list', Array)
#5 {main}
thrown in /varnish.php on line 502

This might be related to #31 but it was never solved.

Any help is appreciated.
Thanks!

Error 503 Backend fetch failed

Hi,

Sorry for my bad english.
i'm trying to use your images on Ubuntu 16.04 but probably i did something wrong.
I tried on remote server (ubuntu 16.04) and on a local server (still ubuntu 16.04) and the problem is the same.

1 - magento2 installation using composer
2 - with docker-compose i started your file (docker-compose.yml)
3 - once finish i've tried to connect to localhost (or to remote ip) but varnish returns Error 503 Backend fetch failed

Where am i wrong? Do you have any tip?

Thank you

Ugo

production?

Hi,

I follow this project for a time and really like it. Did you try it in production?

I was wondering to find a good composition with NGINX SSL and REDIS. That's the best I found.

Thanks!

Suitable for production deployment in swarm mode?

Hello, @fballiano thank you for this repo . This stack is the best that we found for swarm mode ready deployment. How ever , is this suitable for production environments? We are planning to deploy this with Traefik reverse proxy in a 3 node cluster.

Memory usage [M2.4]

Hello,

Is there any way to lower the memory usage of the containers ?

it start at 4Go but it's a neverending increase, with 10-20Mo each second added in usage after launch. It quickly increase to 7, 8Go :/

I'm using Docker For Windows and the M24 branch.

This site can’t be reached

I'm getting "This site can’t be reached" when I am navigating to the base URL. Do I need to add the same in the virtual host?

PHP bcmath extension is missing

Hi,

When I am running magento setup, I am getting an error missing extension PHP Extension bcmath.. I logged into fballiano/nginx-ssl-for-magento2 container, and installed php7.0-bcmath and reloaded nginx, but when I am running service php restart, I am getting error unknown service.

Can you give me any solution for the same?

Thanks

Rahul Anand

Varnish5

I have foudn out that this stack use your vanish version. You have upgrade to varnish5, which is not handled by the VCL file nor the VARNISH.php script downloaded from turpentile extension.

Furthermore, the turpentine extension (the socker.php renamed varnish.php) now use Mage::getStoreConfig() and ::helper() which is NOT defined by you MAGE class defined in updatenode.php

I'm trying to makes things works again by pooling an old Socket.php(varnish.php) file form turpentine extension

Nice project

Your project looks great!

Any plans for having the same with php7-fpm instead of apache?

Thanks!

redis fpc + varnish

Just a question really, why do you need a redis fpc cache when you are using varnish, doesn't varnish replace the redis cache?

Your probe file in the container is a txt file created at startup, in your readme you say it is a css file. Also docker-compose scale is deprecated. Use the up command with the --scale flag instead.

This is a great collection of images and I like the idea of the dynamically scaleable apache servers. I think I would control the varnish cache update from the host though and monitor the container health state to build the array of apache servers available. I guess swarm would make this redundant but for scaling containers on the same host it is stilla neat solutiom.

Error 503 Backend fetch failed on OSX

I did step by step like readme says.
Added magento2.docker into /etc/hosts
Started all containers using docker-compose up -d

Then when I visit magento2.docker I expect to see some setup wizard, but only one I got:

Error 503 Backend fetch failed

Backend fetch failed
Guru Meditation:

XID: 48

Varnish cache server

Also tried to start apache2 manually, but without luck. My host os is macOS 10.14.5 (18F132)

Any suggestions?

Best way to update?

Hi, I see you have updated to php7.4 for Magento 2.4 what is the best way to update the containers please?

eMailing and db backup?

Hi all.

Got this setup implemented. However, system email (transactions, forgot password) don't work. It would be great to have the following also:

  1. eMail setup (maybe php) + smtp.
  2. Database backups.

Any suggestions?

Debian 9

Hello, im using a fresh installation of debian 9.

Got this error:
Fatal error: Uncaught Magento\Framework\Exception\FileSystemException: The file "/var/www/html/var/.regenerate" cannot be deleted Warning!unlink(/var/www/html/var/.regenerate): Permission denied in /var/www/html/vendor/magento/framework/Filesystem/Driver/File.php:382 Stack trace: #0 /var/www/html/vendor/magento/framework/Filesystem/Directory/Write.php(172): Magento\Framework\Filesystem\Driver\File->deleteFile('/var/www/html/v...') #1 /var/www/html/vendor/magento/framework/Code/GeneratedFiles.php(99): Magento\Framework\Filesystem\Directory\Write->delete('/var/.regenerat...') #2 /var/www/html/vendor/magento/framework/App/ObjectManagerFactory.php(110): Magento\Framework\Code\GeneratedFiles->cleanGeneratedFiles() #3 /var/www/html/vendor/magento/framework/App/Bootstrap.php(208): Magento\Framework\App\ObjectManagerFactory->create(Array) #4 /var/www/html/vendor/magento/framework/App/Bootstrap.php(123): Magento\Framework\App\Bootstrap->__construct(Object(Magento\Framework\App\ObjectManagerFactory), '/var/www/html', Array) #5 /var in /var/www/html/vendor/magento/framework/Filesystem/Driver/File.php on line 382

This path /var/www/html/vendor/magento/... doesn't exist, i use docker compose on /home/magento/
and the magento files are inside (/home/magento/magento2). But i forced the installation (myip/setup) it worked, but got same error when i try acesss my site. (Admin page is working /admin)

Can create second db for tests

Can i have a way for create new db for test
example i need creat magento_integration_tests for integration tests db. It's isolate with db magento2 default

Trying to import .sql file

I'm trying to import a .sql dump file

docker exec -i docker-magento2_db_1 mysql -umagento2 -pmagento2 magento2 < /Users/me/dumps/Dump20210121.sql

But it returns

ERROR 1227 (42000) at line 13382: Access denied; you need (at least one of) the SUPER, SET USER privilege(s) for this operation

I've tried a few different solutions posted around the net but nothing seems to work?

Why not use PHP-FPM ?

Hi thank you very much for this project,

I was wondering any advantage of using PHP-FPM vs Apache2 (Modphp option)

Tnx

Use in production (slow)

This is a question regarding the performance of this docker, based on our use case.

We are attempting to create a docker construction for Magento production. Our current attempts have been very slow and many dockers do not seem usable. Are you working on a production-ready environment or do you know of some production ready (magento 2.4).

Currently, our loading times are several seconds, without cache, exceeding 15 seconds. We have around 80k products, totalling around 5000 product attributes. We have a very simple theme and few modules. Our current production runs on CloudWays and has 32Gb RAM, and an 8-core processor.

The docker runs on a dedicated server, with 128G ram, and the following cpu:

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                32
On-line CPU(s) list:   0-31
Thread(s) per core:    2
Core(s) per socket:    8
Socket(s):             2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 79
Model name:            Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz

All cache is enabled.

We are wondering if there are any speed ups to be had, by using optimized configurations, different docker setups, or any other solutions.

Hi fballiano, my stack was keep 504 gateway timeout every where.

Hi fballiano, my stack was keep 504 gateway timeout every where. even i set up
max_input_time, max_execution_time. the file it was in the folder , but URL can not reach that,

environment:
AWS
elastic beanstalk
REDIS(AWS)
MYSQL(AWS RDS)
CDN cloudflare

the 504 time out drive me crazy, i was working on the for 1 month. some times it wait like few hours it works find.

ERROR: "Could not validate a connection to Elasticsearch. No alive nodes found in your cluster"

I get the error below when i try to setup with following command.

Error:

[Progress: 656 / 1315]
Installing search configuration...

In SearchConfig.php line 81:
                                                                                          
  Could not validate a connection to Elasticsearch. No alive nodes found in your cluster 

Command:

php bin/magento setup:install \
  --db-host docker-magento2_db_1 --db-name magento2 --db-user magento2 --db-password magento2  --admin-user admin --timezone 'Europe/Berlin' --currency EUR --use-rewrites 1 --cleanup-database \
  --backend-frontname admin --admin-firstname AdminFirstName --admin-lastname AdminLastName --admin-email '[email protected]' --admin-password 'asdasdasd' --base-url 'https://magento2.docker/' --language en_US \
  --session-save=redis --session-save-redis-host=sessions --session-save-redis-port=6379 --session-save-redis-db=0 --session-save-redis-password='' \
  --cache-backend=redis --cache-backend-redis-server=cache --cache-backend-redis-port=6379 --cache-backend-redis-db=0 \
  --page-cache=redis --page-cache-redis-server=cache --page-cache-redis-port=6379 --page-cache-redis-db=1

Using M2.4 branch on a Ubuntu 20.04

Elasticsearch container is up and running:

CONTAINER ID   IMAGE                                COMMAND                  CREATED          STATUS          PORTS                                                                                  NAMES
f6364a889be7   fballiano/magento2-cron:M2.4         "docker-php-entrypoi…"   21 minutes ago   Up 21 minutes   80/tcp                                                                                 docker-magento2_cron_1
b09be9ac7080   fballiano/nginx-ssl-for-magento2     "/opt/entrypoint.sh …"   21 minutes ago   Up 21 minutes   80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp                                          docker-magento2_ssl_1
9b4f74033e8d   fballiano/varnish:M2.4               "/bin/sh -c /start.sh"   21 minutes ago   Up 21 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:6082->6082/tcp, :::6082->6082/tcp           docker-magento2_varnish_1
a98760d04862   fballiano/magento2-apache-php:M2.4   "docker-php-entrypoi…"   21 minutes ago   Up 21 minutes   80/tcp                                                                                 docker-magento2_apache_1
552cbd6fff7e   elasticsearch:7.6.2                  "/usr/local/bin/dock…"   21 minutes ago   Up 21 minutes   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp   docker-magento2_elasticsearch_1
e478e21e5a11   redis:5                              "docker-entrypoint.s…"   21 minutes ago   Up 21 minutes   6379/tcp                                                                               docker-magento2_sessions_1
cecb76dfb3ba   fballiano/redis-volatile:M2.4        "docker-entrypoint.s…"   21 minutes ago   Up 21 minutes   6379/tcp                                                                               docker-magento2_clusterdata_1
e67b51169f79   fballiano/redis-volatile:M2.4        "docker-entrypoint.s…"   21 minutes ago   Up 21 minutes   6379/tcp                                                                               docker-magento2_cache_1
28df1dbca588   mysql:8.0                            "docker-entrypoint.s…"   21 minutes ago   Up 21 minutes   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp                                   docker-magento2_db_1

Error in documentation

docker exec -it dockermagento2_apache_1 bash
php bin/magento dev:source-theme:deploy
php bin/magento setup:static-content:deploy

it should be

docker exec -it magento2_apache_1 bash
php bin/magento dev:source-theme:deploy
php bin/magento setup:static-content:deploy

XDebug Setup

Hello and thank you for the excellent work!

Any tips on how to setup XDebug on this infrastructure?
I think it is a usefull addition, especially when using this composition for development.

Thanks in advance!

Disable all cache

To development mode, how we can disable all cache? Is good add into README.
Thanks

Installation stuck on database connection step 2, incorrect documentation

Server host localhost -> getting error SQLSTATE[HY000] [2002] No such file or directory
Server host 127.0.0.1 -> getting error SQLSTATE[HY000] [2002] Connection refused
Server host mariadb -> getting error SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
Server host docker-magento2_db_1 -> getting error SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
Server host deab688c09af -> OK!
Server host magento2_db_1 -> OK!

There is a line in documentation, but it is incorrect: instead of docker-magento2_db_1 it has to be magento2_db_1

Any tips to help speed things up?

Hi there,
I've set this up on a macbook pro (2.8 GHz Intel Core i7, 16 GB 1600 MHz DDR3) running Docker CE (Engine: 18.06.0-ce, with 4 CPUs and 7.5GB of memory & 1GB of swap).

In order to get through first installation I had to add this to varnish.vcl:
backend apache_1 {
.host = "apache";
.port = "80";
.first_byte_timeout = 600s;
}
to prevent "Error 503 Backend fetch failed" errors.

However everything seems incredibly slow (minutes for each page load on front end, admin is unnavigable).

I have enabled Redis
(e.g. from the Redis container I get

# redis-cli --scan | head -10
zc:k:792_LAYOUT_FRONTEND_STORE1_3D41D8CD98F00B204E9800998ECF8427E
zc:ti:792_CMS_INDEX_INDEX
zc:k:792_Zend_LocaleC_en_GB_currencytoname_GBP
zc:k:792_TRANSLATE_EN_GB_FRONTEND_DEFAULT_MAGENTO_LUMA_MAGENTO_CUSTOMER
zc:k:792_LAYOUT_ADMINHTML_STORE1_2PAGE_LAYOUT
zc:k:792_DICONFIG774B76ADE48691A57FBFC9E80B5A99CD
zc:k:792_Zend_LocaleC_en_GB_parentlocale_
zc:k:792_Zend_LocaleC_en_US_parentlocale_
zc:k:792_LAYOUT_FRONTEND_STORE1_3
zc:k:792_DB_IS_UP_TO_DATE

)

However it doesn't look like varnish is working properly (I am seeing no signs of caching in the response headers).

Any ideas/ further info I can provide to help figure out why it's running so slowly please?

Many thanks
Ben

Cannot read contents from file

Hi there.
I have tried using this repo with Magento EE 2.2.2, but getting this error:
Fatal error: Uncaught Magento\Framework\Exception\FileSystemException: Cannot read contents from file "/var/www/html/app/etc/di.xml" Warning!file_get_contents(/var/www/html/app/etc/di.xml): failed to open stream: No such file or directory in /var/www/html/vendor/magento/framework/Filesystem/Driver/File.php:149 Stack trace: #0 /var/www/html/vendor/magento/framework/Filesystem/File/Read.php(100): Magento\Framework\Filesystem\Driver\File->fileGetContents('/var/www/html/a...', NULL, NULL) #1 /var/www/html/vendor/magento/framework/Config/FileIterator.php(71): Magento\Framework\Filesystem\File\Read->readAll() #2 /var/www/html/vendor/magento/framework/Config/Reader/Filesystem.php(146): Magento\Framework\Config\FileIterator->current() #3 /var/www/html/vendor/magento/framework/Config/Reader/Filesystem.php(130): Magento\Framework\Config\Reader\Filesystem->_readFiles(Object(Magento\Framework\Config\FileIterator)) #4 /var/www/html/vendor/magento/framework/App/ObjectManagerFactory.php(275): Magento\Framework\Config\Reader\Filesystem-> in /var/www/html/vendor/magento/framework/App/ObjectManagerFactory.php on line 277

Windows 10 (using Powershell or WSL). Folder has all permissions.
When I log into the container (Apache) all files are with roo:root permission. Is this correct?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.