create web app with php and docker
I have the following
FROM php RUN apt-get update && apt-get install -y git RUN git clone https://github.com/marcosh/webinthemiddle.git EXPOSE 80 CMD php -S localhost:80 webinthemiddle/index.php
that I would like to use to create a very basic app with php.
I build the image using
sudo docker build -t marcosh/webinthemiddle . and then I tried running the container using
sudo docker run -d -P marcosh/webinthemiddle
sudo docker run -d -P marcosh/webinthemiddle php -S localhost:80 webinthemiddle/index.php
Then I checked with
sudo docker ps to which port was mapped the port 80 of the container and browser to
localhost:#PORT#, but I found nothing there…
What am I doing wrong?
One Solution collect form web for “create web app with php and docker”
Two things will be helpful for you to debug this:
- When debugging problems like this, start by running the container in the foreground interactively and with a TTY (
-trespectively). Your command would be something like
sudo docker run -i -t -P marcosh/webinthemiddle php -S localhost:80 webinthemiddle/index.php.
- Next, in the Docker container world,
localhostis local to the container (not your host). Since the container is only listening on
localhost, requests from other IP addresses (such as your host) won’t get to the socket. You will want to listen on