I have set up 3 Linux VM through multipass on my host Mac OSX. I have installed docker on these machines and started a 3 node docker swarm.
docker swarm init
After that, I have created 2 services one is for Postgres DB and the other is for drupal with the following command.
docker service create -d --name postgras-db --network test-swarm-network -e POSTGRES_PASSWORD=<password> postgres
docker service create -d --name drupal-frontend --network test-swarm-network -p 80:80 drupal
Port 80:80 is exposed for drupal and both of these services are connected to the same overlay network. My services are up and running.
If I am doing everything on the host machine then I will simply do http://localhost:80 or http://localhost to get the desired output but now when running it in VM how I can test the drupal front from host MAC, i.e which IP to hit in the host browser to get the desired result.
P.S: There is nothing specific here about drupal (it could be any other container like Nginx etc), the question is about accessing running container (inside VM) from host OS
2
Answers
I figured this out myself. For other help:
We can get the info of a running VM by running the following command on host machine.
like
it will give the info about the VM which also contains the IP on which VM is running
From here user can copy the IP address and paste it into the host browser which will hit port 80 (by default) of the VM.
Thanks
You can use below command: