Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container image 312293e does not connect to the database #604

Closed
JGillam opened this issue Jan 16, 2024 · 6 comments
Closed

Container image 312293e does not connect to the database #604

JGillam opened this issue Jan 16, 2024 · 6 comments

Comments

@JGillam
Copy link

JGillam commented Jan 16, 2024

Describe the bug
When building with container image tagged 312293e, the following exception occurs:
Fatal error: Uncaught mysqli_sql_exception: Connection refused in /var/www/html/dvwa/includes/dvwaPage.inc.php:508 Stack trace: #0 /var/www/html/dvwa/includes/dvwaPage.inc.php(508): mysqli_connect('127.0.0.1', 'dvwa', Object(SensitiveParameterValue), '', '3306') #1 /var/www/html/login.php(8): dvwaDatabaseConnect() #2 {main} thrown in /var/www/html/dvwa/includes/dvwaPage.inc.php on line 508

Using the previous container (1fb5078) works normally. I have not had a chance to look into why yet (I'm working with a class on this today) and plan to follow up with more details later.

To Reproduce
This is a container build issue, simply starting with the :latest container from this repo is causing the problem for me, and simply rolling back to :1fb5078 resolves it.

note: I did not provide additional detail below - but will attempt to fill in more detail later today.

Logs
Include the last five lines of the Apache log file from directly after the problem happened.

Expected behaviour
A clear and concise description of what you expected to happen.

What have you done to help fix the issue yourself?
What have you tried, what research have you done, what changes have you made.

Screenshots
If applicable, add screenshots to help explain your problem.

System (please complete the following information):

  • OS: [e.g. Windows, Ubuntu]
  • Database and Version [e.g. MySQL, MariaDB, 10.5.12-MariaDB]
  • PHP Version [e.g. 7.4.25]
  • Installed PHP modules

Additional context
Add any other context about the problem here.

Copy link
Owner

I accepted a PR this morning which changed how the database connection strings worked, I'll roll it back.

@digininja
Copy link
Owner

digininja commented Jan 16, 2024 via email

@digininja
Copy link
Owner

It looks like the database server is missing from the image!

I'll have a quick play but this may be above my docker skills.

@digininja
Copy link
Owner

Agreed it broke after version 1fb5078 but I can't see why.

If you can suggest anything I'll take it. The docker compose is working fine locally.

Hope the class goes well.

@JGillam
Copy link
Author

JGillam commented Jan 17, 2024

I believe I found the source of the problem. I build container labs for students using a template to dynamically generate compose files. It appears an expected environment variable passed through compose was renamed from DB_SERVER to DVWA_DB_SERVER.

So I can fix this on my end by updating my template. In fact, I will simply add both keys. Sorry for the fire drill.

@digininja
Copy link
Owner

digininja commented Jan 17, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants