我尝试在docker下安装laravel 5.0 / mysql“ 5.5” / php_version,但无法在浏览器中定位并植入应用程序: 我有3个配置文件: docker-compose.yml:
version: '3.1'
services:
youtube_api_demo_app:
build:
context: ./web
dockerfile: Dockerfile.yml
container_name: youtube_api_demo_app_container
environment:
- APACHE_RUN_USER=#1000
volumes:
- ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
ports:
- 8085:80
working_dir: ${APP_PTH_CONTAINER}
db:
image: mysql:5.5.62
restart: always
environment:
MYSQL_ROOT_PASSWORD: 1
volumes:
- ${DB_PATH_HOST}:/var/lib/mysql
adminer:
image: adminer
restart: always
ports:
- 8086:8080
links:
- db
youtube_api_demo_composer:
image: composer:1.6
container_name: youtube_api_demo_composer_container
volumes:
- ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
working_dir: ${APP_PTH_CONTAINER}
command: composer install --ignore-platform-reqs
.env:
# PATHS
DB_PATH_HOST=./databases
APP_PATH_HOST=./YoutubeAPI_Demo
APP_PTH_CONTAINER=/var/www/html/
web / Dockerfile.yml:
FROM php:5.6-apache
RUN apt-get update -y && apt-get install -y libpng-dev nano libmcrypt-dev
RUN docker-php-ext-install \
pdo_mysql \
mcrypt \
&& a2enmod \
rewrite
和我的应用程序/YoutubeAPI_Demo/.env的环境:
APP_NAME = Laravel APP_ENV =本地 APP_KEY = base64:4 + BRJbKtSQ7Z7yBVkYxe + NxfLkVPBAG2Gm1I93Qwukc = APP_DEBUG = true APP_URL = http://127.0.0.1:8085/ APP_SUBDIRECTORY =
LOG_CHANNEL =堆栈
DB_USERNAME =根DB_PASSWORD = 1 DB_CONNECTION = mysql DB_HOST = 127.0.0.1:8086 DB_PORT =:8086 DB_DATABASE = youtube_api_demo
我不确定是否设置了有效的DB_HOST和DB_PORT参数,实际上我尝试了不同的方法。
1)我构建了应用程序并进入控制台,但迁移时出错:
# php artisan migrate
[PDOException]
SQLSTATE[HY000] [2002] Connection refused
但是我进入管理员并创建了数据库:https://imgur.com/a/ePBfMiv
2)在浏览器http://127.0.0.1:8085/中输入错误:
You don't have permission to access / on this server.
Apache/2.4.25 (Debian) Server at 127.0.0.1 Port 8085
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a51ccd12ae40 adminer "entrypoint.sh docke…" About an hour ago Up About an hour 0.0.0.0:8086->8080/tcp youtubeapi_demo_adminer_1
7f9ee8f14c9d mysql:5.5.62 "docker-entrypoint.s…" About an hour ago Up About an hour 3306/tcp youtubeapi_demo_db_1
b2c47edaf616 youtubeapi_demo_youtube_api_demo_app "docker-php-entrypoi…" About an hour ago Up About an hour 0.0.0.0:8085->80/tcp youtube_api_demo_app_container
3dcc1a4ce8f0 adminer "entrypoint.sh docke…" 5 weeks ago Up 4 hours 0.0.0.0:8083->8080/tcp lprods_adminer_container
933d9fffaf76 postgres:9.6.10-alpine "docker-entrypoint.s…" 5 weeks ago Up 4 hours 0.0.0.0:5433->5432/tcp lprods_db_container
2f73a600b999 adminer "entrypoint.sh docke…" 6 weeks ago Up 4 hours 0.0.0.0:8082->8080/tcp votes_docker_adminer_1
52ea479b8791 mysql:5.6.41 "docker-entrypoint.s…" 6 weeks ago Restarting (1) 34 seconds ago votes_docker_db_1
配置选项有什么问题?
谢谢!
答案 0 :(得分:1)
1)在.env中:您可以使用:
DB_CONNECTION=mysql
DB_HOST=db // THAT IS MYSQL container name
DB_PORT=3306
2)尝试url
http://127.0.0.1:8085/public
使用通常的laravel 5目录设置