Viewing Docker Compose web app on server outside host machine (the host is OSX) - macos

My computer is OSX. I'm logged into an ssh connection (Ubuntu), and from there I'm ssh'ed into an OpenStack instance of Ubuntu 14.04. From this OpenStack instance I've been following a Docker-Compose tutorial from the Docker docs : https://docs.docker.com/compose/gettingstarted/
I'm on Step 4, and I'm successfully running a server that is running on http://0.0.0.0:5000/
However, I don't know how to view a GUI Google Chrome browser from my Macbook. Because whenever I go to http://0.0.0.0:5000/ it says server not found, which makes sense because it's not on my computer.
I read something about port forwarding, but I'm not sure that's right here. I'm fairly new, so please help!
Also, is this the right way to use an OpenStack machine? That you use your computer's web browser to view the web app?

I solved it myself. Turns out on OpenStack, you need to create a security group and then add it to your instance. When you create a security group, you can add a port that you want to provide public access to. And then you can view the web app on any computer by typing in your floating IP on OpenStack, colon separated by the public port address.

Related

How do I access 127:.0.0.1:5000 on Ubuntu Server 16.04 LTS (HVM), SSD Volume Type

I just started studying flask and built a toy website to see how well I am doing. I have a flask website built in python 3.6 and I have tested it on my windows computer and everything goes very well. Now I want to host the website on an ubuntu ec2 instance. But first, I am testing if everything runs well on my ec2 instance and am stuck at trying to access port 5000 on my ec2 instance My app is currently serving on port 127.0.0.1:5000 of my linux server. I have tried to connect to my.ec2.public.ip:5000 and my.ec2.private.ip:5000 with no success. Could someone help me? Thanks.
By default, your Flask app will listen only on localhost, you need to add host arg in run in make it listen to your actual server's IP.
if __name__ == '__main__':
app.run(host='0.0.0.0', port=80) #or whatever port you want your app to listen to.
To edit the security group of your instance, go to the EC2 instances page and slide to your extreme right, you will have Security Group column. Here click on the security group written in your instance and edit to add the port that you want to open.
By default a new AWS instance would not allow port 5000 to be accessed, so you will need to modify the security group to allow access on that port. You do this thru the AWS console.

How can I access a webpage located inside a VM from the host machine's browser?

I am able to access the link http://localhost/men/tops-men/jackets-men.html successfully from my VM (configured using X2Go client).
IP Address of the VM: 10.146.106.204
I am also able to ping the VM successfully from my host machine (Windows).
The page that I am trying to access is a php page deployed on Apache Web Server.
However I am not able to do so from my Windows host machine.
I tried http://10.146.106.204/men/tops-men/jackets-men.html from my Windows machine but it did not work.
Do I have to configure something on my host machine or on my VM ?
Not sure what I am missing.
On VM check you can view http://10.146.106.204/men/tops-men/jackets-men.html
If not you need to configure the web server to listen on that IP (if you're running IIS this is under "bindings" in the right-hand side panel of IIS Manager).
On Host open a cmd window and check you can ping 10.146.106.204
If not check your firewall settings on the VM.
If neither of these 2 things help then you need to add more information about your setup to the question. Those are 2 very simple things you can do to diagnose 2 basic problems you might be having.
I was finally able to solve the problem based on this SO link: Unable to access magento site from anywhere but localhost
Updated the DB table core_config_data and updated the data by replacing http://localhost with http://ip-of-vm and then restarted the apache web server.

Cannot access macOS Server from the other mac using wifi

This is how it is managed in macOS Server:
and then from the other mac I do:
but it doesn't work, cannot login to remote mac. Why?
User kuna exists on mac with macOS Server and is an admin.
If you want to access your server from inside the office, don’t use the public IP - use the server’s local IP (one of the ones starting 192.168....)
If you want to access your server from outside the office, you may have to configure your office router to forward the relevant traffic to your server. This process is called port forwarding.
I’d
find out the port numbers you need to forward on this page
Google <name of your router> setup port forwarding for how to enter them into your router - although with many routers, the process is pretty self-explanatory in the admin interface.

Unable to access MongoDB within a container within a Docker Machine instance from Windows

I am running Windows 7 on my desktop at work and I am signed in to a regular user account on the VPN. To develop software, we are to normally open a Dev VM and work from in there however recently I've been assigned a task to research Docker and Mongo DB. I have very limited access to what I can install on the main machine.
Here lies my problem:
Is it possible for me to connect to a MongoDB instance inside a container inside the docker machine from Windows and make changes? I would ideally like to use a GUI tool such as Mongo Management Studio to make changes to a Mongo database within a container.
By inspecting the Mongo container, it has the ports listed as: 0.0.0.0:32768 -> 27017/tcp
and docker-machine ip (vm name) returns 192.168.99.111.
I have commented out the 127.0.0.1 binding host ip within the mongod.conf file also.
From what I have researched so far, most users resolve their problem by connecting to their docker-machine IP with the port they've set with -p or been given with -P. Unfortunately for me, trying to connect with 192.168.99.111:32768 does not work.
I am pretty stumped and quite new to this environment. I am able to get inside the container with bash and manipulate the database there however I'm wondering if I can do this within Windows.
Thank you if anyone can help.
After reading Smutje's advice to ping the VM IP and testing it out to no avail, I attempted to find a pingable IP which would hopefully move me closer to my goal.
By doing "ifconfig" within the Boot2Docker VM (but not inside the container), I was able to locate another IP listed under eth0. This IP looks something like 134.36.xxx.xxx to me and is pingable. With the Mongo container running I can now access the database from within Mongo Management Studio by connecting to 134.36.xxx.xxx:32768 and manipulate the data from there.
If you have the option of choosing the operating system for your dev VM, go with Ubuntu and setup docker with all of the the containers you want to test on that. Either way, you will need to have a VM for testing docker on windows since it uses VirtualBox if i'm not mistaken. Instead, setup an Ubuntu VM and do all of your testing on that.

How to access Docker web app from host OS?

I've followed the tutorial on the docker.io website here:
http://docs.docker.io/en/latest/examples/python_web_app/
How would I access this app from a browser on my host OS?
Docker Remote API provides a way of accessing your Docker images and containers and performing many operations on them, through your Browser.
Here is the link for Docker API v1.6 Documentation
Hope it helps.
The tutorial explains how this works:
WEB_PORT=$(sudo docker port $WEB_WORKER 5000)
Look up the public-facing port which is NAT-ed. Find the private port used by the container and store it inside of the WEB_PORT variable.
# install curl if necessary, then ...
curl http://127.0.0.1:$WEB_PORT
Hello world!
Access the web app using curl. If everything worked as planned you should see the line “Hello world!” inside of your console.
Inside the container the application is listening on port 5000. This is translated automatically to an external port number accessible outside of the container. This makes sense because it allows multiple copies of your application to coexist on the same machine, each mapping port 5000 to a uniquely accessible port number for each app instance.
The documentation on port redirection has more details.

Resources