Docker部署PHP应用
1.文件目录
/data/project/demo_docker_php/ ├── docker-compose.yaml └── website └── index.php 1 directory, 2 files
|
2.php文件
文件: index.php
<?php echo "Hello LinuxHub, Test."; ?>
|
3.docker-compose.yaml文件
文件: docker-compose.yaml
version: '2' services: website: image: php:apache volumes: - ./website:/var/www/html ports: - 5002:80
|
4.启动Docker
cd /data/project/demo_docker_php/ docker-compose up -d
|
5.查看Docker镜像
REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/php apache 2d3f459bfbb0 11 days ago 412.1 M
|
6.查看容器与对外端口服务
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 048b3c59f003 php:apache "docker-php-entrypoin" 6 minutes ago Up 6 minutes 0.0.0.0:5002->80/tcp zeze2_website_1 # netstat -nlp | grep 5002 tcp6 0 0 :::5002 :::* LISTEN 14528/docker-proxy-
|
7.访问服务