我有一个这个
的docker容器nginx.conf
server {
listen 80;
index index.php index.html;
root /var/www/public;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
搬运工-compose.yaml
version: '2'
services:
# The Application
app:
build:
context: ./
dockerfile: app.dockerfile
working_dir: /var/www
volumes:
- ./:/var/www
environment:
- "DB_PORT=3306"
- "DB_HOST=database"
# The Web Server
web:
build:
context: ./
dockerfile: web.dockerfile
working_dir: /var/www
volumes_from:
- app
ports:
- 85:80
# The Database
database:
image: mysql:5.6
volumes:
- dbdata:/var/lib/mysql
environment:
- "MYSQL_DATABASE=homestead"
- "MYSQL_USER=homestead"
- "MYSQL_PASSWORD=secret"
- "MYSQL_ROOT_PASSWORD=secret"
ports:
- "33062:3306"
volumes:
dbdata:
docker似乎构建并成功启动
docker-compose up -d
docker_app_1 is up-to-date
docker_database_1 is up-to-date
Recreating docker_web_1 ...
Recreating docker_web_1 ... done
但我一直在
找不到档案。
如何继续进行调试?
我现在对任何建议持开放态度。
任何提示/建议/帮助都将非常感谢!
答案 0 :(得分:2)
所有卷和其他目录设置理想地指向同一位置。在你的nginx.conf中你有root / var / www / public;但在你的yal你使用/ var / www。那可能是你的问题。
对于要继续的步骤,您可以在启动docker-compose.yml文件后使用以下命令检查服务实际使用的目录:
docker-compose exec yourServiceName sh
将yourServiceName替换为您在yaml中定义的任何服务。您上面的yaml中有 app , web 或数据库。该命令将带您进入特定容器的shell(sh)。您还可以将 sh 替换为其他命令,以便对容器执行其他操作。
答案 1 :(得分:1)
使用docker exec -it xxxxxx bash
启动容器一旦你这样做,你将在容器内。现在根据docker-compose文件检查文件是否位于您放置它们的位置。