{"id":13629367,"url":"https://github.com/alexcheng1982/docker-magento2","last_synced_at":"2025-05-15T15:07:13.885Z","repository":{"id":28283822,"uuid":"31796108","full_name":"alexcheng1982/docker-magento2","owner":"alexcheng1982","description":"Docker image for Magento Open Source 2","archived":false,"fork":false,"pushed_at":"2024-12-10T00:44:33.000Z","size":106,"stargazers_count":387,"open_issues_count":47,"forks_count":260,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-04-07T20:11:18.387Z","etag":null,"topics":["docker-image","magento2"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexcheng1982.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"alexcheng1982","github":"alexcheng1982"}},"created_at":"2015-03-07T01:00:17.000Z","updated_at":"2025-03-06T13:39:51.000Z","dependencies_parsed_at":"2024-12-15T12:00:55.440Z","dependency_job_id":"82086d24-f65b-4075-8d79-76be6deff94d","html_url":"https://github.com/alexcheng1982/docker-magento2","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcheng1982%2Fdocker-magento2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcheng1982%2Fdocker-magento2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcheng1982%2Fdocker-magento2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcheng1982%2Fdocker-magento2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexcheng1982","download_url":"https://codeload.github.com/alexcheng1982/docker-magento2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254364270,"owners_count":22058878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker-image","magento2"],"created_at":"2024-08-01T22:01:08.674Z","updated_at":"2025-05-15T15:07:08.871Z","avatar_url":"https://github.com/alexcheng1982.png","language":"Dockerfile","funding_links":["https://ko-fi.com/alexcheng1982","https://github.com/sponsors/alexcheng1982"],"categories":["Dockerfile"],"sub_categories":[],"readme":"# Docker Image for Magento Open Source 2\n\n[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/alexcheng1982)\n\n**This repo ONLY maintains Docker images for Magento Open Source 2.4.x. You may still found Docker images for old versions in the [old registry](https://quay.io/repository/alexcheng1982/magento2).**\n\n**Starting from Magento 2.4.x, container images are now hosted in [GitHub Container Registry](https://github.com/alexcheng1982/docker-magento2/pkgs/container/docker-magento2).**\n\nThis repo provides Docker images for different Magento 2.4 versions. Refer to [this page](https://github.com/alexcheng1982/docker-magento2/pkgs/container/docker-magento2/versions) to see all available versions.\n\n| Version    | PHP Version | Container image                                  |\n| ---------- | ----------- | ------------------------------------------------ |\n| `2.4.6-p3` | `8.1`       | `ghcr.io/alexcheng1982/docker-magento2:2.4.6-p3` |\n| `2.4.5-p5` | `8.1`       | `ghcr.io/alexcheng1982/docker-magento2:2.4.5-p5` |\n| `2.4.4-p6` | `8.1`       | `ghcr.io/alexcheng1982/docker-magento2:2.4.4-p6` |\n\nThis docker image is based on my [docker-apache2-php8](https://github.com/alexcheng1982/docker-apache2-php8) image for Apache 2 and PHP 8. Please refer to the image label `php_version` for the actual PHP version. In general, Magento uses PHP `8.1` starting from `2.4.4`. Versions `2.4.2` and `2.4.3` use PHP `7.4`. Please refer to the label `php_version` of the image to get the actual PHP version.\n\n\u003e This docker image is based on [phusion/baseimage-docker](https://github.com/phusion/baseimage-docker) with Ubuntu 22.04 LTS. The reason to use `phusion/baseimage-docker` is to support multiple processes, which is important to get cronjobs working in Magento.\n\n**Please note: this Docker image is for Magento 2 related development and testing only, not ready for production use. Setting up a Magento 2 production server requires more configurations. You can use this image as the base to build customized images.**\n\n## Magento 2 Installation Types\n\nMagento 2.4 can be installed using [Composer](https://getcomposer.org/) or git. The git-based installation mode is used for contributor of Magento. This Docker image uses Composer as the installation type, so the **Web Setup Wizard** can be used. \n\nBelow are some basic instructions.\n\n## Quick Start\n\nThe easiest way to start Magento 2 with MySQL is using [Docker Compose](https://docs.docker.com/compose/). Just clone this repo and run the following command in the directory of a specific version. For example, go to `versions/2.4.6-p3` for Magento `2.4.6-p3`.\n\nThe default `docker-compose.yaml` uses MySQL, phpMyAdmin, and OpenSearch.\n\n~~~\n$ docker compose up -d\n~~~\n\nFor admin username and password, please refer to the file `env`. You can also change the file `env` to update those configurations. Below are the default configurations.\n\n~~~\nMYSQL_HOST=db\nMYSQL_ROOT_PASSWORD=myrootpassword\nMYSQL_USER=magento\nMYSQL_PASSWORD=magento\nMYSQL_DATABASE=magento\n\nMAGENTO_LANGUAGE=en_GB\nMAGENTO_TIMEZONE=Pacific/Auckland\nMAGENTO_DEFAULT_CURRENCY=NZD\nMAGENTO_URL=http://local.magento\nMAGENTO_BACKEND_FRONTNAME=admin\nMAGENTO_USE_SECURE=0\nMAGENTO_BASE_URL_SECURE=0\nMAGENTO_USE_SECURE_ADMIN=0\n\nMAGENTO_ADMIN_FIRSTNAME=Admin\nMAGENTO_ADMIN_LASTNAME=MyStore\nMAGENTO_ADMIN_EMAIL=amdin@example.com\nMAGENTO_ADMIN_USERNAME=admin\nMAGENTO_ADMIN_PASSWORD=magentorocks1\n\nOPENSEARCH_HOST=opensearch\n~~~\n\nFor example, if you want to change the default currency, just update the variable `MAGENTO_DEFAULT_CURRENCY`, e.g. `MAGENTO_DEFAULT_CURRENCY=USD`.\n\nTo get all the possible values of `MAGENTO_LANGUAGE`, `MAGENTO_TIMEZONE` and `MAGENTO_DEFAULT_CURRENCY`, run the corresponding command shown below:\n\n| Variable                   | Command                          |\n| -------------------------- | -------------------------------- |\n| `MAGENTO_LANGUAGE`         | `bin/magento info:language:list` |\n| `MAGENTO_TIMEZONE`         | `bin/magento info:timezone:list` |\n| `MAGENTO_DEFAULT_CURRENCY` | `bin/magento info:currency:list` |\n\nFor example, to get all possible values of `MAGENTO_LANGUAGE`, run\n\n```bash\n$ docker run --rm -it ghcr.io/alexcheng1982/docker-magento2:2.4.6-p3 info:language:list\n```\n\nYou can find all available options in the official [guide](https://experienceleague.adobe.com/docs/commerce-operations/configuration-guide/cli/common-cli-commands.html?lang=en). If you need more options, fork this repo and add them in `bin\\install-magento`.\n\nPlease see the following video for a quick demo.\n\n[![Use Magento 2 with Docker](https://img.youtube.com/vi/18tOf_cuQKg/hqdefault.jpg)](https://www.youtube.com/watch?v=18tOf_cuQKg \"Use Magento 2 with Docker\")\n\n## Installation\n\nAfter starting the container, you'll see the setup page of Magento 2. You can use the script `install-magento` to quickly install Magento 2. The installation script uses the variables in the `env` file. Use `docker ps` to find the container name.\n\n### Magento 2\n\n~~~\n$ docker-compose exec web install-magento\n~~~\n\n### Sample data\n\n~~~\n$ docker-compose exec web install-sampledata\n~~~\n\n\n### Database\n\nThe default `docker-compose.yml` uses MySQL as the database and starts [phpMyAdmin](https://www.phpmyadmin.net/). The default URL for phpMyAdmin is `http://localhost:8580`. Use MySQL username and password to log in.\n\nMySQL `8.0.0` is used as the default database version.\n\n### Usage\n\nAfter Magento 2 is installed, open a browser and navigate to `http://local.magento/`. For admin access, navigate to `http://local.magento/admin/` and log in using the admin username and password specified in the `env` file. Default admin username and password are `admin` and `magentorocks1`, respectively. Two-factor authentication is disabled.\n\n### Running on Windows\n\nWhen running on Windows, the port `80` may be occupied by built-in IIS or ASP.NET server. The following command finds ID of the process that occupies port `80`.\n\n```\nnetstat -ano -p TCP | find /I\"listening\" | find /I\"80\"\n```\n\nThen `taskkill /F /PID \u003cpid\u003e` can be used to kill the process to free the port.\n\n## FAQ\n\n### How to update Magento 2 version?\n\nTo update Magento 2 version, fork this repository and modify `update.js`. In the `versions` array, add a new version with Magento 2 version number and PHP version. The base image [docker-apache2-php8](https://github.com/alexcheng1982/docker-apache2-php8) has PHP versions `8.1`, `8.2`, and `8.3`.\n\nRun `update.js` using NodeJS. Files of the new version will be generated in directory `versions/\u003cversion_name\u003e`. Run `docker build` in the version's directory to build the container image.\n\n### How to use a different port?\n\nIf the default port `80` cannot be used for some reasons, you can change to a different port. Simply change the `MAGENTO_URL` from `http://local.magento` to add the port number, for example, `http://local.magento:8080`. You may also need to modify `docker-compose.yaml` file to update the exported port of the Magento container.\n\n### How to keep installed Magento?\n\nYou can add a volume to folder `/var/www/html`, see the `docker-compose.yml` file.\n\n```yaml\nvolumes: \n  - magento-data:/var/www/html \n```\n\n### Where is the database?\n\nMagento 2 cannot run without a database. This image is for Magento 2 only. It doesn't contain a MySQL server. A MySQL server should be started in another container and linked with Magento 2 container. It's recommended to use Docker Compose to start both containers. You can also use [Kubernetes](https://kubernetes.io/) or other tools.\n\n### Why accessing http://local.magento?\n\nFor development and testing in the local environment, using `localhost` as Magento 2 URL has some issues. The default `env` file use `http://local.magento` as the value of `MAGENTO_URL`. You need to [edit your `hosts` file](https://support.rackspace.com/how-to/modify-your-hosts-file/) to add the mapping from `local.magento` to `localhost`. You can use any domain names as long as it looks like a real domain, not `localhost`.\n\nIf `localhost` doesn't work, try using `127.0.0.1`.\n\n```\n127.0.0.1    local.magento\n```\n\n\n### How to update Magento 2 installation configurations?\n\nDepends on how the container is used,\n\n* When using the GUI setup page of Magento 2, update configurations in the UI.\n* When using the script, update configurations in the `env` file. \n* When starting Magento 2 as a standalone container, use `-e` to pass environment variables.\n\n### Why getting access denied error after changing the default DB password?\n\nIf you change the default DB password in `env` file and get the access denied error when installing Magento 2, see [this issue comment](https://github.com/alexcheng1982/docker-magento2/issues/10#issuecomment-355382150).\n\n## Develop and test using this Docker image\n\nAs I mentioned before, this Docker image is primarily used for development and testing. Depends on the tasks you are trying to do, there are different ways to use this Docker image.\n\n### Extensions and themes\n\nYou can keep the extensions and themes directories on your local host machine, and use Docker Compose [volumes](https://docs.docker.com/compose/compose-file/#volumes) to install the extensions and themes. For example, if you have a theme in the directory `/dev/mytheme`, you can install it by specifying it in the `docker-composer.yaml` file. Then you can see the theme in Magento admin UI.\n\n```yml\nversion: '3.0'\nservices:\n  web:\n    image: ghcr.io/alexcheng1982/docker-magento2:2.4.6-p3\n    ports:\n      - \"80:80\"\n    links:\n      - db\n    env_file:\n      - env\n    volumes:\n      - /dev/mytheme:/var/www/html/app/design/frontend/mytheme/default\n```\n\n### Modify Magento core files\n\nIf you want to modify Magento core files, you cannot modify them directly in the container. Those changes will be lost. It's also not recommended to update Magento core files directly, which makes upgrading Magento a painful process. Actually, Docker makes the process much easier if you absolutely need to modify some core files. You can use volumes to overwrite files.\n\nFor example, if you want to overwrite the file `app/code/Magento/Catalog/Block/Product/Price.php`, you can copy the content to a new file in your local directory `/dev/mycode/magento_2_2` and make the changes, then use `volumes` to overwrite it.\n\n```yml\nvolumes:\n  - /dev/mycode/magento_2_2/app/code/Magento/Catalog/Block/Product/Price.php:/var/www/html/app/code/Magento/Catalog/Block/Product/Price.php\n```\n\nBy using Docker, we can make sure that all your changes to Magento core files are kept in one place and tracked in source code repository. These changes are also correctly aligned with different Magento versions.\n\nWhen deploying those changes to production servers, we can simply copy all files in the `/dev/mycode/magento_2_2` directory to Magento installation directory and overwrite existing files.\n\n### Test Magento compatibilities\n\nThis Docker images has different tags for corresponding Magento 2.4 versions. You can switch to different Magento versions very easily when testing extensions and themes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexcheng1982%2Fdocker-magento2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexcheng1982%2Fdocker-magento2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexcheng1982%2Fdocker-magento2/lists"}