Must start with host = 0.0.0.0. By default, it listens at 127.0.0.1, but this is just listening inside the container. If you access it from the host pc with curl localhost, it will be converted to another internal ip when communicating inside the container. Therefore, if you listen on 127.0.0.1, you cannot respond. Therefore, listen with 0.0.0.0. This will listen on all interfaces in the container. Therefore, it becomes possible to respond.
↓ Code is supposed to be mounted on/app
FROM centos:centos8
RUN dnf module install -y php:7.4
WORKDIR /app
CMD [ "php", "artisan", "serve", "--port=80", "--host=0.0.0.0" ]
reference https://qiita.com/amuyikam/items/01a8c16e3ddbcc734a46
Recommended Posts