Victor Bocharsky
Victor Bocharsky

Reputation: 12306

How to see Nginx default page using vagrant docker provider?

I try to run my Nginx server using vagrant docker provider like:

vagrant up

The Vagrantfile instructions are:

# Specify Vagrant version and Vagrant API version
Vagrant.require_version ">= 1.6.0"
VAGRANTFILE_API_VERSION = "2"
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'docker'

# Create and configure the Docker container(s)
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.network "private_network", ip: "192.168.66.66"

  config.vm.provider "docker" do |docker|
    docker.name = 'nginx-container'
    docker.image = "nginx:latest"
    docker.ports = ['80:80', '443:443']
  end
end

If I check status of vagrant with vagrant status I get:

Current machine states:

default                   running (docker)

The container is created and running. You can stop it using
`vagrant halt`, see logs with `vagrant docker-logs`, and
kill/destroy it with `vagrant destroy`.

When I try to get http://192.168.66.66/ page, I get ERR_CONNECTION_TIMED_OUT and page not load. Why I don't see Nginx default web page?

The logs during vagrant up in console are:

==> default: Docker host is required. One will be created if necessary...
    default: Docker host VM is already ready.
==> default: Syncing folders to the host VM...
    default: Installing rsync to the VM...
    default: Rsyncing folder: /Users/victor/www/symfony/ => /var/lib/docker/docker_1430638235_29519
==> default: Warning: When using a remote Docker host, forwarded ports will NOT be
==> default: immediately available on your machine. They will still be forwarded on
==> default: the remote machine, however, so if you have a way to access the remote
==> default: machine, then you should be able to access those ports there. This is
==> default: not an error, it is only an informational message.
==> default: Creating the container...
    default:   Name: nginx-container
    default:  Image: nginx:latest
    default: Volume: /var/lib/docker/docker_1430638235_29519:/vagrant
    default:   Port: 80:80
    default:   Port: 443:443
    default:
    default: Container created: b798ea3309612fb2
==> default: Starting container...
==> default: Provisioners will not be run since container doesn't support SSH.

Upvotes: 1

Views: 1061

Answers (1)

GustavoH
GustavoH

Reputation: 413

This is several months old, but I'll answer anyway for the sake of other people that might land here:

Use docker ps to see your image identifier, should be 'b798ea3309612fb2'

and then do:

docker inspect b798ea3309612fb2 | grep IPAddress

So you'll confirm the IP address.

Since you're exposing the ports, you should see them in your REAL (whatever container you're using for Vagrant) IP. Make sure there is no firewall blocking them.

Upvotes: 2

Related Questions