Question on port forwarding

18 views
Skip to first unread message

Sorcerer Stone

unread,
Mar 25, 2020, 3:48:24 PM3/25/20
to Vagrant
Vagrantup.com described the general guideline of port forwarding usage.
I have a question which I think the answer is most likely No. But need confirmation from others as I am self-learning.

In a docker compose file, say defining the db service for setting up postgres, there are ports statement like

ports:
  - "5432:5432"

Am I correct to say internal ports like this that are need to communicate with other services/running containers (that are placed on the same network) do not need port forwarding to be define in the vagrantfile (aka, in this example, port 5432 need not be forwarded as host OS does not use it)?

Correct?

Thanks in advance.
SStone

Alvaro Miranda Aguilera

unread,
Mar 25, 2020, 4:10:56 PM3/25/20
to vagra...@googlegroups.com
Hello

The answer to your question I believe is a yes as you mention, as you say you want internal services.

have you tested ?



--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/f5a62767-21fb-44ca-90d2-890f9b07b1f9%40googlegroups.com.


--
Alvaro

Sorcerer Stone

unread,
Mar 25, 2020, 5:38:20 PM3/25/20
to Vagrant
Hello Alvaro,
Indeed I have. But I am running into problems and I am guessing port conflicts is the cause. But it could be others such as port forwarding. Hence my question.
I have 2 separate projects which has its own Postgres, and one has its own Nginx.
On their own, I can use Vagrant file to call up the Compose yml file and containers all running in each of these project and I can access the app through the browser.
But when I put the 2 separate projects into one big compose file and make sure the ports used in Postgres are different for each of these apps services. Containers are running but the app got errors like "Network not found" or something like that when I tried to access them.
So, I am looking into could the problem be in port forwarding. But it make no sense to forward internal ports onto the host OS.
I will keep hacking. Thanks for the confirmation about no need to forward ports used internally among containers in the guest OS.
SStone.

On Wednesday, March 25, 2020 at 4:10:56 PM UTC-4, Alvaro Miranda Aguilera wrote:
Hello

The answer to your question I believe is a yes as you mention, as you say you want internal services.

have you tested ?



On Wed, Mar 25, 2020 at 8:48 PM Sorcerer Stone <sorcer...@gmail.com> wrote:
Vagrantup.com described the general guideline of port forwarding usage.
I have a question which I think the answer is most likely No. But need confirmation from others as I am self-learning.

In a docker compose file, say defining the db service for setting up postgres, there are ports statement like

ports:
  - "5432:5432"

Am I correct to say internal ports like this that are need to communicate with other services/running containers (that are placed on the same network) do not need port forwarding to be define in the vagrantfile (aka, in this example, port 5432 need not be forwarded as host OS does not use it)?

Correct?

Thanks in advance.
SStone

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagra...@googlegroups.com.


--
Alvaro

Alvaro Miranda Aguilera

unread,
Mar 29, 2020, 10:21:21 AM3/29/20
to vagra...@googlegroups.com
Hello
If you stop the VM from Virtualbox, and then start from VirtualBox GUI, you wont be using vagrant at all

If you still have port issues, then could be how the ports get assigned inside the VM.

I dont believe this is a Vagrant isuse as vagrant is running your scripts after creating the VM

Alvaro


To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/c4e75b6a-f59a-489b-babd-aef54b447041%40googlegroups.com.


--
Alvaro

Reply all
Reply to author
Forward
0 new messages