推荐答案
-- -------------------- ---- ------- -- ---- - --- --- ------ -- --- -------- -- ---- -------------------------- ------------ --------- ------------- - ----- --- -------- ---- ----------- - ------ ------- ---- - ----------------- ---- --- ---- - ---- - -- --- -- --- ---------------------- --------- - ---- ------ -- - -- --- ----- --- ------- ----- -------------
创建 docker-compose.yml 文件:在项目根目录下创建一个名为
docker-compose.yml
的文件,内容如下:version: '3' services: web: build: . ports: - "8080:80" volumes: - .:/app
构建并运行容器:在项目根目录下运行以下命令来构建并启动容器:
docker-compose up --build
访问应用:在浏览器中访问
http://localhost:8080
,即可看到部署的 PHP 应用。
-- -------------------- ---- ------- -- ------ --- -- ---------- --- ---------- -------------------------- ------ ------------------ --- ------------------ ----------- ----- --- ------ ----- ---- --- -- ------------------ --- -------------------- ------------ ------ ------------------- ----- ------------- ---------- ---------- -- -------- ---- ------------ --------------- ------ -------------------- --- -- ------- --------------- -- -------- ---------------------- ------------------ --- -- ---- ------ -- -------- ---- -------------- ----------------------- ------ --- --- --- -- ------ - ------- ----- ------- -------------------- ----- ---- ------ --- --------- - --------------- --- ----- ----- - ---------- --- ------