开始响起时无法连接到我的Docker容器IP

时间:2019-03-01 15:02:14

标签: laravel docker swoole

我在laravel项目中使用(或尝试使用)swoole。当我查看容器日志时,它说:

Starting swoole http server...
Swoole http server started: <http://127.0.0.1:1215>

但是当我访问IP地址时,出现连接错误:

This site can’t be reached 127.0.0.1 refused to connect.

我的docker-compose.yml:

version: '3'

services:
    web:
        build:
            dockerfile: ./environment/nginx/Dockerfile
            context: .
        volumes:
            - ./api:/var/www/

Dockerfile:

FROM php:7.3

# Swoole version
ENV SWOOLE_VERSION=4.2.1

# install swoole
RUN cd /tmp && curl -sSL "https://github.com/swoole/swoole-src/archive/v${SWOOLE_VERSION}.tar.gz" | tar xzf - \
        && cd swoole-src-${SWOOLE_VERSION} \
        && phpize && ./configure > /dev/null && make > /dev/null && make install > /dev/null \
        && docker-php-ext-enable swoole

# install pdo extension
RUN docker-php-ext-install pdo_mysql > /dev/null

# Add volume to workdir
WORKDIR /var/www/


# Install unzip
RUN apt-get update -yqq > /dev/null
RUN apt-get install -yqq git unzip > /dev/null

# Add swoole to env
RUN echo "APP_SWOOLE=true" >> .env

# Start swoole
CMD php artisan swoole:http start

我还尝试过将端口添加到docker compose文件中,如下所示:

ports:
 - 1215:1215

但是那没有用,也没有。

0 个答案:

没有答案