How do i deploy flask to virtual-box using vagrant? - vagrant

I created a flask application and I want to deploy it to a virtual box using vagrant, what needs to be on the vagrantfile for the application to run on the virtual box?

Related

Can't access my flask app running on my virtual machine

I'm running a Ubuntu 18.10 LTS virtual box on my Windows 10 system.
In the network configuration I set the network to bridge.
After that my virtual machine appears in my local network with the ip 192.168.0.231.
A ping from my hosting system to the VM works fine.
I'm then starting a flask app with DEBUG=TRUE, TEST=TRUE, SERVER_NAME=127.0.0.1:5001. On the VM the server starts and is available under localhost:5001.
But from my hosting service I get Could not get any response, when I try to access 192.168.0.231:5001.
Do I have to open some ports on the VM?
Thanks!
You need to:
Start the VM with the port forwarded and be sure it is not used on your Host OS
use when starting the app --host=0.0.0.0 if you start it with flask run

Accessing Host machine urls from Ubuntu VM

I have an Ubuntu VM on my windows host machine. I have installed Hashicorp consul on my windows host machine. I am trying to run docker container and trying to access the consul url from the VM using ip. But I am unable to do so.
Is there a way where I can access any host machine url from the ubuntu virtual machine. I am not able to access any url of app deployed on host machine from vm.

How to put files into Vagrant?

I did an internship and they used vagrant so all the developers whould run the same latest version of the web application.
But now i want to create my own vagrant webserver.
I got to the point that i setup vagrant using the hashicorp/precise32 box.
I got nginx running on my own special ip adress that i changed in the hosts file.
So now i can go to mytestsite.com and it will show me welcome to nginx.
But now my question is, how can i get my own file(small test web application) into the vagrant server because i do not know how to transfer my files to vagrant.
And how can i let my friends use my vagrant test web application.
Thank you for your help!
Sincerely Mex
19 years old
web application student in the Netherlands
By default vagrant will have a synced folder between your vm and the host machine. It is in the same folder as the vagrantfile and can accessed through /vagrant on your host machine.
However if you want more customization and mount certain folders on your host machine and sync them to the vagrant VM it can be done in the vagrant file as follows:
Vagrant.configure("2") do |config|
# other config here
config.vm.synced_folder "src/", "/srv/website"
end
Here is a quick guide to get you started using vagrants synced folders and the example i posted

How to access docker container service from outside world like from parent windows host machine

As part of "How to access docker container service from outside world like from parent windows host machine "
I followed the following step :
1) On windows machine(10.204.255./16) , I created vagrant VM (172.17.0./24) . Inside vagrant VM I created different docker images based on my requirements.
2) As part of docker image creation, created centos:6.6 images and run installed ACE-TAO service inside that.
3) TAO service is running properly, and it is binding with the specific container ip: specific port (like 172.17.0.10:13021)
Reference: Able to create images and run the images to create container and install TAO rpm and TAO service running successfully.
Issues is like i'm not able to ping this ip from outside world like from my windows machine
I'm attaching my dockerfile here
FROM centos:6.6
MAINTAINER praveen
WORKDIR /root/
ADD TAO-1.7.7-0.x86_64.rpm /root/TAO-1.7.7-0.x86_64.rpm
RUN rpm -ivh TAO-1.7.7-0.x86_64.rpm
CMD ["/etc/init.d/tao", "start"]
EXPOSE 13021
I believe this is common usecase of docker is like :
Installed service on dockerized container with are accessible from host machine , if we try to access with ip:port
ACE-TAO behavior is like ,rpm installed to specific host , so we can access corba service from this url : corba://(tao_service_runnig_ip):(listening port)
In order to meet this requirement , i need to access the from host machine

How create an ssh connection from vagrant to a specific virtual machine? Can I create a connection to a VM installed on WMware?

I am absolutly new in Vagrant and in Apache Storm.
I am following an online course where show the following situation.
1) There is an Ubuntu virtual machine installed on Virtual Box
2) On the physic machine (the same where is installed Virtual Box and that run the Ubuntu VM) it is installed Vagrant
Ok, from the physic machine, it log into the virtual machine using this statment:
vagrant ssh
and show that it is created a connection to the installed Ubuntu VM.
Here the first doubt: how it know what is the exact virtualized system? What happen if I have installed more than one VM on Virtual Box (with the previous command it is not specified to what installed VM have to be connected)
Another doubt is: I don't use Virtual Box but I use WMware workstation? How can I use the vagrand ssh command to create a connection to a specific VM installed on my WMware workstation?
I'd try to answer a few points from your question -
First, in vagrant language the physic machine will be the host and the VM is called the guest (or guest VM)
Vagrant knows how to connect to the VM it did create as it maintains the Id of the created VM into a .vagrant directory where you have initialized the Vagrantfile.
You can run vagrant global-status and you will have an output with all the VMs that vagrant managed along with the Id, Name and Provider information.
The provider can be VirtualBox or VMWare or anything else. The same in the .vagrant directory you will have subdirectory for the provider (e.g. a directory .vagrant/machines/default/virtualbox or .vagrant/machines/default/vmware_xxx) by default vagrant will start the Virtualbox provider but you can specify the --provider=XXX option when setting up the VM for the 1st time and then vagrant will create the VM for this specific provider and further command on this VM (ssh, reload ...) will work on this specific provider.

Resources