yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce
systemctl start docker
docker version
docker info
docker run hello-world
將會看到訊息:
Hello from Docker!
This message shows that your installation appears to be working correctly.
===================================================================================
yum install curl
curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
將會看到訊息:
docker-compose version 1.27.4, build 40524192
===================================================================================
將專案 Download 下來,我們在Symfony底下,docker目錄結構應該會像下列這樣
docker-image/
│
├── docker-compose.yml
│
├── data/
│ └── my.cnf
│
├── php-fpm/
│ ├── composer.sh
│ ├── Dockerfile
│ ├── php.ini
│ ├── supervisord.conf
│ └── www.conf
│
└─── nginx/
└── default.conf
之後在 docker-image/ 底下執行指令
docker-compose up -d --build
將會看到訊息:
Creating network "docker-image_symfony" with the default driver
Creating mysql ... done
Creating php-fpm ... done
Creating nginx ... done
docker-compose ps
將會看到訊息:
Name Command State Ports
------------------------------------------------------------------------------------
mysql docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp, 33060/tcp
nginx /docker-entrypoint.sh ngin ... Up 0.0.0.0:80->80/tcp
php-fpm /usr/bin/supervisord -c /e ... Up 0.0.0.0:9000->9000/tcp
http://<ServerIP>
將會看到訊息:
Welcome to Symfony <version>
Your application is now ready. You can start working on it at:
/usr/share/nginx/html/
http://<ServerIP>/message
若無法執行composer安裝腳本請參考 "https://getcomposer.org/download/" 最新發布版安裝