The plain HTML example you’re showing is not using PHP. And the word “static” in the topic title also suggests you may not need any programming language at all?
Thanks for the reply. I need php because in the .php pages I include some pieces of html code. I also use the if and for loops as well.
I don’t know which tag to use, there are too many options and I don’t know what code I need to write in the Dockerfile.
Tomorrow I’ll try to write something, thanks.
If you don’t specify a version or specific base image in the tag, you’ll use the most common and latest. So, with a file index.php that holds, say, <?php phpinfo(); ?> the following command, run from the folder that holds that file, should already allow you to browse to http://localhost to see the information page:
docker run --rm -p 80:80 -v "$PWD":/var/www/html php:8.1-apache
If I write: http://localhost/
I am sent back to: https://localhost/
If I write: http://localhost/index.php
the page is reached.
Is there a way to remove the redirect to https?
I use this code:
There is no redirect to HTTPS by default. Try it from an incognito window in your browser so if you tested SSL on localhost before, the browser will not remember that. If it doesn’t help, then it must be caused by your configuration or code.
$(pwd) instead of $PWD actually works in bash on Linux and in Powershell on Windows too.
It is very strange and I do not understand why such a thing happens, however it is true, if I open an incognito window I have no problems. I use Linux Ubuntu 22.04 LTS on vmware. Docker doesn’t work on Windows. Thank you
It is simply because. HTTP redirection can be permanent or temporary. Redirecting from HTTP to HTTPS is often permenent. If you try something on localhost, the browser saves that information and will continue to redirect even if the server doesn’t send the “Location” header in the HTTP response.
Docker does work on Windows and you can run Linux containers too, since Docker Desktop runs Docker in a virtual machine. It is just harder to configure in some cases.
I wonder, did you really want to accept your post as a solution instead of the answer from @avbentem who actually told you which image you could use and gave you an example?
Thank you very much, all clear. On Windows it’s agony to install Docker, I’ve given up. I prefer to use Docker inside Ubuntu and inside Vmware. I corrected the tick on solution. Thanks for both of your contributions.