craftcms / nitro

Speedy local dev environment for @craftcms.
https://getnitro.sh
MIT License
178 stars 24 forks source link

Can’t provide valid port for web-based UI using `container new` command #318

Closed mattstein closed 3 years ago

mattstein commented 3 years ago

Description

I’m using nitro container new to spin up a phpMyAdmin container for some docs I work on. A strange port is suggested and I know I want a web-based UI.

Everything goes great when I answer Y for exposing the suggested port and Y again for the UI:

❯ nitro container new
What image are you trying to add? phpmyadmin
Which image should we use?
  1. phpmyadmin
  2. phpmyadmin/phpmyadmin
  3. bitnami/phpmyadmin
  4. nazarpc/phpmyadmin
  5. jackgruber/phpmyadmin
  6. rkcreation/phpmyadmin
  7. drud/phpmyadmin
  8. silintl/phpmyadmin
  9. maxexcloo/phpmyadmin
  10. sk278/phpmyadmin-armhf
Enter your selection: 1
What tag should we use [latest]?
  … downloading docker.io/library/phpmyadmin:latest ✓
Expose port `1025` on host [Y/n]? Y
Does the image contain a web based UI [Y/n]? Y
What is the name of the container [phpmyadmin]?
Create a file to add environment variables [Y/n]? Y
Created environment variables file at "/Users/mattstein/.nitro/.phpmyadmin"...
New container "phpmyadmin.containers.nitro" added! 🐳
Apply changes now [Y/n]? Y

# normal stuff omitted

If I decline to expose 1025 (because what is it?) and answer Y for a web-based UI things get weird:

❯ nitro container new
What image are you trying to add? phpmyadmin
Which image should we use?
  1. phpmyadmin
  2. phpmyadmin/phpmyadmin
  3. bitnami/phpmyadmin
  4. nazarpc/phpmyadmin
  5. jackgruber/phpmyadmin
  6. rkcreation/phpmyadmin
  7. drud/phpmyadmin
  8. silintl/phpmyadmin
  9. maxexcloo/phpmyadmin
  10. sk278/phpmyadmin-armhf
Enter your selection: 1
What tag should we use [latest]?
  … downloading docker.io/library/phpmyadmin:latest ✓
Expose port `1025` on host [Y/n]? n
Does the image contain a web based UI [Y/n]? Y
Which port should we use for the UI?
Enter your selection: 80
Please choose a valid option…
Which port should we use for the UI?12345
Please choose a valid option…
Which port should we use for the UI?8090
Please choose a valid option…
Which port should we use for the UI?

In attempting to provide a UI port, there are three problems:

  1. 80 is an invalid option, and yet 80 and 443 are the only good guesses I have.
  2. The subsequent prompts for a valid port no longer include Enter your selection:, but have me entering input immediately after the question mark.
  3. I am unable to guess any valid option but don’t have any hints.

I noticed adding another image that the multiple ports it exposed were provided as options for the web-based UI, which makes me think exposing zero ports means there are zero valid options to select for a web-based UI. If that’s the case, it seems like it might be best to avoid the Does the image contain a web based UI question altogether.

Steps to reproduce

  1. Use nitro container new to add the phpmyadmin image, choosing Y to expose the suggested port and Y again for a web-based UI.
  2. Use nitro container new to again add the phpmyadmin image, but choosing n for exposing the suggested port, Y for the web-based UI, and observe being stuck in an endless input loop of despair.

Additional info

jasonmccallister commented 3 years ago

Just pushed the change that should resolve this here https://github.com/craftcms/nitro/commit/7ac8bd667ecc58facbe60f98d7e1dbff0200f539

@mattstein can you pull and build to verify its working as intended?

mattstein commented 3 years ago

Works great @jasonmccallister, thank you! 👍

jasonmccallister commented 3 years ago

Released with v2.0.8.