Skip to content

Morerice/Magento2-Docker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Building a Docker image

cd into the location of Dockerfile and then run:

docker build -t tag_name .

Running a Docker Image

Run with specific port mapping and deattached:

docker run -d -p 80:80 --name name_of_container name_of_image[:tag]
docker run -d -p 80:80 --name magento magento2

If Nginx-reverse proxy is running, use VIRTUAL_HOST env variable:

docker run -d -e VIRTUAL_HOST=magento2.ataberkylmz.com --name magento magento2

Nginx reverse proxy needs the image to have EXPOSE 80 or other EXPOSE ports in the Dockerfile.

Running Nginx Reverse Proxy

docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy

Running MariaDB Image

docker run -d --net backend --name mariadb -e MARIADB_USER=magento -e MARIADB_PASSWORD=magento -e MARIADB_ROOT_PASSWORD=root -e MARIADB_DATABASE=magento mariadb:10.4

Running MySQL Image

docker run --name mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=magento -e MYSQL_USER=magento -e MYSQL_PASSWORD=magento -d mysql:8.0

With the above, you can only connect to it from other containers if you know the ip address of it in the bridge network. However, if you create another network and add both of the containers, you can ping it by container name.

Creaating Network

In order to create a network, run the below command

docker network create network_name

Connecting Containers to a Network

Run the below code to connect to a container to a network:

docker network connect network_name container_name

Running Elasticsearch

docker run -d -m 512m --name elasticsearch --net backend -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.16.2

Running Magento 2 Image from Dockerhub

docker run -d -e VIRTUAL_HOST=magento2.ataberkylmz.com -e DB_SERVER=mariadb -e ELASTICSEARCH_SERVER=elasticsearch -e MAGENTO_HOST=magento2.ataberkylmz.com --net backend --name magento ataberkylmz/magento2:2.4.2

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 70.2%
  • Dockerfile 29.8%