89838
お世話になっております。

昨夜docker環境で dbコンテナが立ち上がらない問題（解決済み）に直面したのですが、  
今度はwebでlocalhostが表示されなくなってしまいました。

現状の状況を下記に書かせていただきます。  
よろしくお願いします....。

### docker-compose.yml

```

    version: '3'
    services:
      web:
        build: ./docker/web
        container_name: test_web
        ports:
          - "8080:80"
        volumes:
          - ./:/var/www/test
        working_dir: /var/www/test
        privileged: true
        depends_on:
          - db
        (一部抜粋)
    
```

## Dockerfile

```

    FROM amazonlinux:2
    
    RUN yum -y update
    
    RUN rm -rf /etc/localtime
    RUN cp /usr/share/zoneinfo/Japan /etc/localtime
    
    RUN yum install -y \
      sudo \
      wget \
      tar \
      unzip \
      yum-utils \
      git \
      vim \
      crontabs
    
    RUN amazon-linux-extras install php8.0
    RUN yum -y --enablerepo=amzn2extra-php8.0 install \
      php \
      php-cli \
      php-common \
      php-devel \
      php-fpm \
      php-gd \
      php-intl \
      php-json \
      php-mbstring \
      php-mcrypt \
      php-mysqlnd \
      php-pdo \
      php-xml
    
    RUN yum install php-pear gcc make -y \
      && pecl install xdebug
    
    RUN curl -sS https://getcomposer.org/installer | php \
      && mv composer.phar /usr/local/bin/composer
    
    RUN sudo amazon-linux-extras install nginx1.12 \
      && systemctl enable nginx.service \
      && systemctl enable php-fpm.service
    
    ENV NODE_VERSION v16.6.1
    ENV NVM_DIR /root/.nvm
    
    RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash \
      && [ -s $NVM_DIR/nvm.sh ] && \. $NVM_DIR/nvm.sh \
      && nvm install $NODE_VERSION \
      && nvm alias default $NODE_VERSION \
      && nvm use default
    
    ENV PATH $NVM_DIR/versions/node/$NODE_VERSION/bin:$PATH
    
    RUN yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
    RUN yum -y --enablerepo=mysql80-community install mysql-community-client
    
    RUN mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.org
    RUN mv /etc/php.ini /etc/php.ini.org
    
    COPY conf/www.conf    /etc/php-fpm.d/
    COPY conf/conf.d/     /etc/nginx/conf.d/
    COPY conf/nginx.conf  /etc/nginx/
    COPY conf/php.ini     /etc/
    
    RUN mkdir /run/httpd
    
    CMD ["/sbin/init"]
    
```

## 実行コマンド

```

    $ docker-compose build --no-cache
    $ docker-compose up
    $ docker-compose exec web bash
    # composer install
    # cp .env.example .env
    # php artisan storage:link
    # chmod 777 ./storage
    # chmod 777 ./bootstrap/cache
    
```

## 問題が起きるまでにやったこと

  * dbコンテナがdemonの問題で動かなくなったので  
「`chown mysql:mysql /var/run/mysqld`」を実行

  * OSのアップデート
  * dockerのアップデート

## 現状

  * docker上は全てのコンテナがrunning中
  * 各コンテナにも入れるがChromeで「localhost:8080」をみようとすると  
「llocalhost からデータが送信されませんでした。」が表示される

  * 「`curl localhost:8080`」で確認したところ  
「`curl: (52) Empty reply from server`」と出力

  * webコンテナ内で「`curl localhost:8080`」で確認したところ  
「 `curl: (7) Failed to connect to localhost port 8080 after 0 ms: Connection
refused`」と出力

  * 「 `cat /var/log/httpd/error_log `」でエラーを確認

```

    [Fri Jul 08 06:04:34.046176 2022] [suexec:notice] [pid 32] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Fri Jul 08 06:04:34.062713 2022] [lbmethod_heartbeat:notice] [pid 33] AH02282: No slotmem from mod_heartmonitor
    [Fri Jul 08 06:04:34.062844 2022] [http2:warn] [pid 33] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
    [Fri Jul 08 06:04:34.134886 2022] [core:error] [pid 33] (2)No such file or directory: AH00099: could not create /run/httpd/httpd.pid.xUvxAq
    [Fri Jul 08 06:04:34.134923 2022] [core:error] [pid 33] AH00100: httpd: could not log pid to file /run/httpd/httpd.pid
    [Fri Jul 08 06:04:45.026097 2022] [suexec:notice] [pid 34] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Fri Jul 08 06:04:45.042733 2022] [lbmethod_heartbeat:notice] [pid 35] AH02282: No slotmem from mod_heartmonitor
    [Fri Jul 08 06:04:45.042820 2022] [http2:warn] [pid 35] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
    [Fri Jul 08 06:04:45.054556 2022] [core:error] [pid 35] (2)No such file or directory: AH00099: could not create /run/httpd/httpd.pid.kFmi8f
    [Fri Jul 08 06:04:45.054574 2022] [core:error] [pid 35] AH00100: httpd: could not log pid to file /run/httpd/httpd.pid
    
```

  * 「mkdir /run/httpd」実行
  * 「`docker-compose stop`」 後 「`docker-compose up`」
  * 再びコンテナ内で「 `cat /var/log/httpd/error_log `」

```

    [Fri Jul 08 06:34:20.907690 2022] [suexec:notice] [pid 30] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Fri Jul 08 06:34:20.920239 2022] [lbmethod_heartbeat:notice] [pid 31] AH02282: No slotmem from mod_heartmonitor
    [Fri Jul 08 06:34:20.920397 2022] [http2:warn] [pid 31] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
    [Fri Jul 08 06:34:20.954746 2022] [mpm_prefork:notice] [pid 31] AH00163: Apache/2.4.53 () configured -- resuming normal operations
    [Fri Jul 08 06:34:20.954780 2022] [core:notice] [pid 31] AH00094: Command line: '/usr/sbin/httpd'
    
```

## 追記

OSのアップデートもしていたので追記します  
OS：「Mac Monterey」  
チップ： 「Apple M1」
CC BY-SA 4.0
2022-07-08T07:31:03.447
89837
2022-07-08T08:26:43.137
2022-07-08T08:01:30.490
53436
53436
question
docker docker-compose
dockerでwebコンテナは立ち上がっているのにブラウザでlocalhostを確認すると「localhost からデータが送信されませんでした。」が表示される
Nginx パッケージのインストールと設定をした後、デーモンが起動されていないのが原因のように見えます。

過去の [類似質問](https://ja.stackoverflow.com/q/68641) の記述を参考にすると、Dockerfile
の末尾辺りに以下の記述が必要かと思います。

```

    ENTRYPOINT /usr/sbin/php-fpm && /usr/sbin/nginx -g "daemon off;"
    
```
CC BY-SA 4.0
2022-07-08T08:26:43.137
89838
2022-07-08T08:26:43.137
3060
89837
answer