无法使用带有Visual Studio代码的远程容器扩展名的主机浏览器打开localhost。
如果从VSCode命令<%for (StudentClass sc: message) {%>
<span><%=sc.name%></span><br>
<%}%>
展开并从浏览器中打开Remote-Containers: Reopen in Container
,将显示http://localhost
。
但是,如果直接从主机执行命令,则Laravel顶部屏幕将在502 Bad Gateway
处打开。
是否缺少远程容器设置?
docker-compose.yml
http://localhost/
php-dockerfile
version: '3'
services:
php:
container_name: php
build: ./docker/php
volumes:
- ./server:/var/www
nginx:
image: nginx
container_name: nginx
ports:
- 80:80
volumes:
- ./server:/var/www
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php
db:
image: mysql:8.0
container_name: db-host
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: database
MYSQL_USER: docker
MYSQL_PASSWORD: docker
TZ: 'Asia/Tokyo'
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
volumes:
- ./docker/db/data:/var/lib/mysql
- ./docker/db/my.conf:/etc/mysql/conf.d/my.cnf
- ./docker/db/sql:/docker-entrypoint-initdb.d
ports:
- 3306:3306
nginx错误日志
FROM php:7.3-fpm
COPY php.ini /usr/local/etc/php/
RUN apt-get update \
&& apt-get install -y libzip-dev \
&& docker-php-ext-install zip pdo_mysql
#Composer install
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
RUN php composer-setup.php
RUN php -r "unlink('composer-setup.php');"
RUN mv composer.phar /usr/local/bin/composer
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /composer
ENV PATH $PATH:/composer/vendor/bin
WORKDIR /var/www
RUN composer global require "laravel/installer"
答案 0 :(得分:0)
已通过更改此文件解决。
.devcontainer / docker-compose.yml
评论出来的是command: ...
# Overrides default command so things don't shut down after the process ends.
# command: /bin/sh -c "while sleep 1000; do :; done"