cd into the location of Dockerfile and then run:
docker build -t tag_name .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 magento2If Nginx-reverse proxy is running, use VIRTUAL_HOST env variable:
docker run -d -e VIRTUAL_HOST=magento2.ataberkylmz.com --name magento magento2Nginx reverse proxy needs the image to have EXPOSE 80 or other EXPOSE ports in the Dockerfile.
docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxydocker 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.4docker run --name mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=magento -e MYSQL_USER=magento -e MYSQL_PASSWORD=magento -d mysql:8.0With 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.
In order to create a network, run the below command
docker network create network_nameRun the below code to connect to a container to a network:
docker network connect network_name container_namedocker run -d -m 512m --name elasticsearch --net backend -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.16.2docker 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