add: wp-env start --disable-port-mapping option #65944
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Adding a
--disable-port-mapping
option to thewp-env start
CLI command that causes the wp-env container to not have any exposed ports.Why?
There's currently no way to have multiple instances of
wp-env
stacks running locally all on port 80/443. This becomes a problem if we want to run containers that are accessed by a reverse proxy sidecar, or for example, the built in DNS functionality of Orbstack.Note that these services generally expose the endpoints at a hostname that does not allow configuration of alternate ports. Combined with the WordPress automatic port redirection, it ends up with an incompatible situation with the reverse proxy listening on port 80/443 but the user agent getting redirected to the customised port.
It's also problematic when we have other services running on port 80/443, but still want to be able to run our
wp-env
stack on those ports.How?
Simply removes the
ports
configuration from all the containers if the flag is passed in.Testing Instructions
wp-env start --disable-port-mapping
docker ps
and you should see the wp-env stack without any ports forwarded.wp-env start
docker ps
and you should see the expected ports being forwarded.