I tested it on Docker for Mac 4.3.1 and M1 Mac according to this post.
I created a phoenix project and did mix deps.get as follows after docker build -t elixir-env .:
docker run --mount type=bind,source=$(pwd),target=/app -p 4000:4000 --rm elixir-env:latest mix phx.new --no-ecto test
cd test
docker run --mount type=bind,source=$(pwd),target=/app -p 4000:4000 --rm elixir-env:latest mix deps.get
Then, I launched a pax-server as follows:
docker run --mount type=bind,source=$(pwd),target=/app -p 4000:4000 --rm elixir-env:latest mix phx.server
Though I viewed http://localhost:4000 by a web browser on the host, I can't connect the phx.server.
Hi Susumu ( @zacky1972 ). Thanks for your question.
It seems like if you want to generate a new phoenix project you are asked if you want to install dependencies. Docker exits abruptly on that question without adding -it to the run command. Can I get you to try your above example again, but instead do:
docker run -it--mounttype=bind,source=$(pwd),target=/app -p 4000:4000 --rm elixir-env:latest mix phx.new --no-ectotest
cd test
This should allow you to install the dependencies interactively.
But the actual issue is a change that happened to the config/dev.exs file, only allowing access from the same computer. Just change the http in that file to allow access from 0.0.0.0 like so:
# from this:http:[ip:{127,0,0,1},port:4000],# to this:http:[ip:{0,0,0,0},port:4000],
Then launch the phoenix server again with:
docker run --mounttype=bind,source=$(pwd),target=/app -p 4000:4000 --rm elixir-env:latest mix phx.server
Hi,
I tested it on Docker for Mac 4.3.1 and M1 Mac according to this post.
I created a phoenix project and did
mix deps.get
as follows afterdocker build -t elixir-env .
:Then, I launched a
pax-server
as follows:Though I viewed
http://localhost:4000
by a web browser on the host, I can't connect thephx.server
.What wrong?
Hi Susumu ( @zacky1972 ). Thanks for your question.
It seems like if you want to generate a new phoenix project you are asked if you want to install dependencies. Docker exits abruptly on that question without adding
-it
to therun
command. Can I get you to try your above example again, but instead do:This should allow you to install the dependencies interactively.
But the actual issue is a change that happened to the
config/dev.exs
file, only allowing access from the same computer. Just change thehttp
in that file to allow access from0.0.0.0
like so:Then launch the phoenix server again with:
Btw, I liked your talks at Elixir Conf.
I did it according to your answer and it was done! Thank you so much.
And also, thank you for watching and listening to my talk!