tomsik68 / docker-xampp

Dockerfile to build an image containing XAMPP(MySQL + PHP + PHPMyAdmin) running on Debian system with SSH server
https://hub.docker.com/r/tomsik68/xampp/
MIT License
197 stars 109 forks source link

Confused with /www #28

Closed Logan1x closed 3 years ago

Logan1x commented 3 years ago

Solved but got new problem see the comment below.

~Hey I used your Docker image to run my project with xampp. Before that I was testing with simple index.php file with printing my name in it.~

I used this dockerfile,

FROM tomsik68/xampp:latest

COPY . ~/my_web_pages

after that I built the container with this command,

docker build -t newtestwithnewcontainer .
docker run -p 41061:22 -p 41062:80  -it -v ~/my_web_pages:/www newtestwithnewcontainer

but http://localhost:41062/www/ shows only this image

So the server is running fine, but I think I am getting confused with /www directory. Can you help me out?

Logan1x commented 3 years ago

CC : @tomsik68

Logan1x commented 3 years ago

Now that I am able to run the test PHP script. I went into my actual folder and tried to run that. It ran successfully but not able to fetch data. I have simple webpage which taking form data and on clicking save button redirecting to reg.php file. But on http://localhost:41062/www/reg.php nothing opens.

Logan1x commented 3 years ago

Here is the repo link, if you want to look at code. https://github.com/Logan1x/php-docker

tomsik68 commented 3 years ago

Hi, I cloned your repo, started your container like this docker run -p 41062:80 -it newtestwithnewcontainer. Then, I created record database and ran your sql script on it in phpmyadmin. This is what I see on localhost:41062. image

Then, I tried to click the add new button. And I got the following php error:

[23-Feb-2021 17:35:10 Europe/Berlin] PHP Fatal error:  Uncaught PDOException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column `record`.`mydb`.`Sno` at row 1 in /www/reg.php:17
Stack trace:
#0 /www/reg.php(17): PDOStatement->execute(Array)
#1 {main}
  thrown in /www/reg.php on line 17

I had to check /opt/lampp/logs/php_error_log inside the container to find the error, but php should display errors. Since this is meant to be developer-friendly cotainer, I created #29 to track this.

Quick glance at your code suggests that your ':sno' => '' association causes this. https://github.com/Logan1x/php-docker/blob/c3852e26a1a1468d71b07dc6c832241005162e35/reg.php#L17

Logan1x commented 3 years ago

Thank you for helping out with this. Do I have to create db every time I built it? I want to push my project on docker hub so the person who is downloading image have to do create db ?

tomsik68 commented 3 years ago

I think there's a way to create the DB inside the container. You can copy your sql script to the container and then import it with mysql cli.

Please beware that this image is not ready for production. This is merely a development environment.

Logan1x commented 3 years ago

Thanks I'll look into it.