Although I have tried so many docker-compose projects, I didn’t find any project that matches my requirement:
- Uses only Official Images.
- Simply enough to setup/modify.
- No extra deployment step from host to containers after changing the code.
So I have created a docker-compose project. Below are the reasons for you to use or not use it:
- Running Magento 2 project really fast on your machine.
- Just a few steps to setup.
- No extra step to deploy code from host to container.
- Easy to modify PHP, MySQL, and Nginx configurations.
- Works on Linux, macOS, and Windows.
Disadvantages (can be reduced in future releases):
- Lack of advanced tools like Redis, Varnish, XDebug.
- Lack of Environment variables configuration.
- Lack of tests on various types of projects.
You can now jump to the Github project or read the installation instruction below (Linux only).
1. Install Docker & docker-compose
// Install Docker
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sh get-docker.sh
// Install docker-compose
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
// Check docker status
$ docker info
If you install docker with a non-root user, you will have permission issue, this is how to fix:
// Create the docker group if it does not exist
$ sudo groupadd docker
// Add your user to the docker group.
$ sudo usermod -aG docker $USER
// Run the following command or Logout and login again and run (that doesn't work you may need to reboot your machine first)
$ newgrp docker
// Check if docker can be run without root
$ docker run hello-world
2. Getting started
It’s time to jump to the project README.md.
3. Some useful notes
Stop all other running containers to prevent port confliction:
// Stop all containers
$ docker stop $(docker ps -a -q)
// Stop all containers from system startup
$ docker update --restart=no $(docker ps -a -q)
Remove old unused images to reclaim disk space:
$ docker image prune -a
This post will be updated frequently