Martin LeFleur
Martin LeFleur

Reputation: 25

Ghost Blog on Ubuntu Snappy Core OS

I have Ghost Blog running inside a Snappy VM using these commands: vagrant init ubuntu/ubuntu-15.04-snappy-core-stable vagrant up && vagrant ssh

docker pull ghost docker run -d -p 80:2368 -v /home/ubuntu/blog --name hello-world ghost

Now that the blog is running, how can I view it from the outside world?

Upvotes: 1

Views: 291

Answers (2)

Martin LeFleur
Martin LeFleur

Reputation: 25

I edited the Vagrantfile and enabled the forwarded port mapping: config.vm.network "forwarded_port", guest: 80, host: 8080 , then vagrant reload and vagrant ssh, Now I am logged into the Snappy VM, and start ghost again, docker run -d -p 80:2368 -v /home/ubuntu/blog --name test ghost , then do the port mapping: enter : docker port be2f474bb8c9 , which reveals 2368/tcp -> 0.0.0.0:80 At this point, I was hoping to browse to localhost:8080 and see my ghost blog. Thank you both!

Upvotes: 0

Paul Becotte
Paul Becotte

Reputation: 9997

Martin- what do you mean by "outside world"?

It looks like you started a virtual machine on your development machine using vagrant, and then fired up a docker container on that virtual machine.

Your docker command publishes the port ghost listens on (2368) to port 80 of the machine that docker is listening on. That is NOT your dev machine though- it is the vagrant virtualbox! This means that on your host machine you cannot run go to localhost to view your blog. (Though, you could ping it from inside the virtualbox using that address...)

What you need to do is find the IP address of your vagrant virtualbox. SSH in using vagrant ssh. Then run ifconfig and get the IP address of your box. (you'll need to know a bit here- my vagrant box actually shows this on eth1 instead of eth0)

You can make this easier in a few ways. You can hard-code an ip address into your vagrantfile...

ip_address = "192.168.33.17"
Vagrant.configure("2") do |config|

  config.vm.network :private_network, ip: ip_address

Further, you can use the vagrant plugin 'hostmanager' to specify a /etc/hosts entry on your machine that will allow you to point your browser at a hardcoded address and vagrant will always point it at the right machine. If you have that installed (vagrant plugin install vagrant-hostmanager)you can modify your vagrantfile with

  config.hostmanager.enabled = true
  config.hostmanager.manage_host = true
  config.vm.define project_name do |node|
    node.vm.hostname = "myghostblog.com"
    node.vm.network :private_network, ip: ip_address
    node.hostmanager.aliases = [ "www.myghostblog.com" ]
  end

If you actually mean you want your blog to be visible from the public internet, that is not something you want to do on your private computer without a ton of knowledge that you don't have (or else you wouldn't need to ask :) ).

Upvotes: 1

Related Questions