Не уверен, что это возможно, но у меня на MacBook есть окно Vagrant с ubuntu 18.04, работающее в VirtualBox.У меня также есть Docker-контейнер, работающий на моем Mac, в котором есть база данных postgres.
Я хотел бы иметь возможность подключиться из Ubuntu к базе данных в Docker.
Моя первая попыткапри этом было добавить следующее к моему VagrantFile
config.vm.network "forwarded_port", guest: 5432, host: 5432
Однако это привело к следующей ошибке:
Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 5432 is already in use
on the host machine.
To fix this, modify your current project's Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:
config.vm.network :forwarded_port, guest: 5432, host: 1234
Sometimes, Vagrant will attempt to auto-correct this for you. In this
case, Vagrant was unable to. This is usually because the guest machine
is in a state which doesn't allow modifying port forwarding. You could
try 'vagrant reload' (equivalent of running a halt followed by an up)
so vagrant can attempt to auto-correct this upon booting. Be warned
that any unsaved work might be lost.
Я понимаю ошибку, это имеет смысл, потому что хост ужепрослушивание порта 5432 (точнее, контейнера docker / postgres).но я не знаю, как решить проблему.Если я сделаю так, как предложено, и поменяю номер порта хоста, он не будет работать, потому что тогда я не буду подключаться к нужному порту.
Предложения?