Access docker container running in coreos on vagrant vm through browser in host ubuntu host

cutteeth

I have setup coreos running in vagrant VM. I want to setup private docker registry. I pulled registry and I can run it. The following is the output on running registry

 core@core-01 ~ $ docker run -p 5000:5000 registry
2014-12-22 01:40:32 [1] [INFO] Starting gunicorn 19.1.0
2014-12-22 01:40:32 [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
2014-12-22 01:40:32 [1] [INFO] Using worker: gevent
2014-12-22 01:40:32 [20] [INFO] Booting worker with pid: 20
2014-12-22 01:40:32 [23] [INFO] Booting worker with pid: 23
2014-12-22 01:40:32 [24] [INFO] Booting worker with pid: 24
2014-12-22 01:40:32 [25] [INFO] Booting worker with pid: 25
2014-12-22 01:40:32 [1] [INFO] 4 workers
22/Dec/2014:01:40:32 +0000 WARNING: Cache storage disabled!
22/Dec/2014:01:40:32 +0000 WARNING: LRU cache disabled!
22/Dec/2014:01:40:32 +0000 DEBUG: Will return docker-registry.drivers.file.Storage
22/Dec/2014:01:40:32 +0000 WARNING: Cache storage disabled!
22/Dec/2014:01:40:32 +0000 WARNING: LRU cache disabled!
22/Dec/2014:01:40:32 +0000 WARNING: Cache storage disabled!
22/Dec/2014:01:40:32 +0000 DEBUG: Will return docker-registry.drivers.file.Storage
22/Dec/2014:01:40:32 +0000 WARNING: LRU cache disabled!
22/Dec/2014:01:40:32 +0000 DEBUG: Will return docker-registry.drivers.file.Storage
22/Dec/2014:01:40:32 +0000 WARNING: Cache storage disabled!
22/Dec/2014:01:40:32 +0000 WARNING: LRU cache disabled!
22/Dec/2014:01:40:32 +0000 DEBUG: Will return docker-registry.drivers.file.Storage
2014-12-22 02:40:32 [1] [INFO] 4 workers
2014-12-22 03:40:31 [1] [INFO] 4 workers
2014-12-22 03:53:42 [1] [INFO] 4 workers
2014-12-22 03:53:42 [1] [INFO] Handling signal: winch
2014-12-22 03:53:42 [1] [INFO] 4 workers
2014-12-22 03:53:43 [1] [INFO] 4 workers
2014-12-22 03:53:43 [1] [INFO] Handling signal: winch
2014-12-22 03:53:43 [1] [INFO] 4 workers

In my ubuntu host machine my ifconfig output shows the below content

me@mydesktop-Machine-Node00:~$ ifconfig
docker0   Link encap:Ethernet  HWaddr 56:84:7a:fe:97:99  
      inet addr:172.17.42.1  Bcast:0.0.0.0  Mask:255.255.0.0
      UP BROADCAST MULTICAST  MTU:1500  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)


eth0  Link encap:Ethernet  HWaddr d4:3d:7e:a1:25:1e  
      inet addr:192.168.65.27  Bcast:192.168.65.255  Mask:255.255.255.0
      inet6 addr: fe80::d63d:7eff:fea1:251e/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:457483 errors:0 dropped:0 overruns:0 frame:0
      TX packets:245109 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:492304997 (492.3 MB)  TX bytes:20414914 (20.4 MB)

lo Link encap:Local Loopback

On accessing 172.17.42.1:5000 and 192.168.65.27:5000 in browser on ubuntu host shows waiting for a long time but finally it doesnt connect.

I refered to this post, but my vagrant dont have entries mentioned as per the post.

My vagrant file is as below

# -*- mode: ruby -*-
# # vi: set ft=ruby :

require 'fileutils'

Vagrant.require_version ">= 1.6.0"

CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data")
CONFIG = File.join(File.dirname(__FILE__), "config.rb")

# Defaults for config options defined in CONFIG
$num_instances = 1
$update_channel = "alpha"
$enable_serial_logging = false
$vb_gui = false
$vb_memory = 1024
$vb_cpus = 1

# Attempt to apply the deprecated environment variable NUM_INSTANCES to
# $num_instances while allowing config.rb to override it
if ENV["NUM_INSTANCES"].to_i > 0 && ENV["NUM_INSTANCES"]
  $num_instances = ENV["NUM_INSTANCES"].to_i
end

if File.exist?(CONFIG)
  require CONFIG
end

Vagrant.configure("2") do |config|
  # always use Vagrants insecure key
  config.ssh.insert_key = false

  config.vm.box = "coreos-%s" % $update_channel
  config.vm.box_version = ">= 308.0.1"
  config.vm.box_url = "http://%s.release.core-os.net/amd64-      
usr/current/coreos_production_vagrant.json" % $update_channel

  config.vm.provider :vmware_fusion do |vb, override|
    override.vm.box_url = "http://%s.release.core-os.net/amd64-  
usr/current/coreos_production_vagrant_vmware_fusion.json" % $update_channel
  end

  config.vm.provider :virtualbox do |v|
    # On VirtualBox, we don't have guest additions or a functional vboxsf
    # in CoreOS, so tell Vagrant that so it can be smarter.
    v.check_guest_additions = false
    v.functional_vboxsf     = false
  end

  # plugin conflict
  if Vagrant.has_plugin?("vagrant-vbguest") then
    config.vbguest.auto_update = false
  end

  (1..$num_instances).each do |i|
    config.vm.define vm_name = "core-%02d" % i do |config|
      config.vm.hostname = vm_name

      if $enable_serial_logging
        logdir = File.join(File.dirname(__FILE__), "log")
        FileUtils.mkdir_p(logdir)

        serialFile = File.join(logdir, "%s-serial.txt" % vm_name)
        FileUtils.touch(serialFile)

        config.vm.provider :vmware_fusion do |v, override|
          v.vmx["serial0.present"] = "TRUE"
          v.vmx["serial0.fileType"] = "file"
          v.vmx["serial0.fileName"] = serialFile
          v.vmx["serial0.tryNoRxLoss"] = "FALSE"
        end

        config.vm.provider :virtualbox do |vb, override|
          vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
          vb.customize ["modifyvm", :id, "--uartmode1", serialFile]
        end
      end

      if $expose_docker_tcp
        config.vm.network "forwarded_port", guest: 2375, host: ($expose_docker_tcp + i -     
1), auto_correct: true
      end

      config.vm.provider :vmware_fusion do |vb|
        vb.gui = $vb_gui
      end

      config.vm.provider :virtualbox do |vb|
        vb.gui = $vb_gui
        vb.memory = $vb_memory
        vb.cpus = $vb_cpus
      end

      ip = "172.17.8.#{i+100}"
      config.vm.network :private_network, ip: ip

      # Uncomment below to enable NFS for sharing the host machine into the coreos-vagrant VM.
      #config.vm.synced_folder ".", "/home/core/share", id: "core", :nfs => true, :mount_options => ['nolock,vers=3,udp']

      if File.exist?(CLOUD_CONFIG_PATH)
         config.vm.provision :file, :source => "#{CLOUD_CONFIG_PATH}", :destination =>     "/tmp/vagrantfile-user-data"
        config.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true
      end

    end
  end
end

How to run docker-registry on coreos-vagrant and connect to it using browser running on host machine?

Alex Nauda

I can see two issues with what you're trying to do.

  1. You are having trouble accessing docker containers running in a Vagrant VM from your host OS.
  2. You are looking for a web UI for administration of your private docker registry, but the docker image I think you are running (library/registry) does not provide this.

Item 1: Please note that the private docker registry you are running does not provide an admin web UI. The service it's providing on port 5000 is not a website; it is for use by command line docker for pushing and pulling images in your private registry. If you need an admin web UI you might consider running an additional service such as https://github.com/atc-/docker-registry-web (which I have not tried but looks promising).

Item 2: If you want to access ports of a Vagrant-VM-hosted docker container from your Vagrant VM's host OS (presumably Windows or OSX, since if your host OS were Linux you probably wouldn't need Vagrant) then I recommend that you open an ssh tunnel to your CoreOS Vagrant VM, forwarding the docker registry port to your local host:

vagrant ssh -L5000:localhost:5000 -L8080:localhost:8080 -L80:localhost:80

And leave that ssh session open as long as you need network access to those docker containers' ports.

While these port forwarding tunnels are open, the ports you forwarded will be available on localhost (i.e. 127.0.0.1). You need not access them via some other IP address as you tried before. This would allow you to access, for example, a web server running in a docker container by visiting http://localhost/ or an application server running on port 8080 by visiting http://localhost:8080/ with a browser or other HTTP client such as curl. Port 5000 is probably useless in this context, because the docker command line utilities that can access the registry don't currently run natively on Windows or OSX. To use your private docker registry, run something like this on your CoreOS Vagrant VM:

docker tag eb62f9df0657 localhost:5000/myimage
docker push localhost:5000/myimage

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Access docker container running in coreos on vagrant vm through browser in host ubuntu host

From Dev

Run docker container on Linux VM which is running on Linux host system

From Dev

Access Web UI running in docker container running on remote host

From Dev

Accessing web application running inside a docker container in host browser?

From Dev

Access VM with SSH through VM host

From Dev

How to access mysql running in docker container from host machine?

From Dev

Running docker on Ubuntu: mounted host volume is not writable from container

From Dev

Docker: copy data from host to mounted host directory to access it from the running container

From Dev

Docker: copy data from host to mounted host directory to access it from the running container

From Dev

Using rsync on windows with vagrant running a CoreOS VM

From Dev

Running a Docker container that accept traffic from the host

From Dev

Running GUI apps on docker container with a MacBookPro host

From Dev

Running GUI apps on docker container with a MacBookPro host

From Dev

Running as a host user within a Docker container

From Dev

Slow network access to vagrant VM when host connected to wifi

From Dev

Cannot access Elasticsearch 2.0 in Vagrant VM from host OS

From Java

How to access host port from docker container

From Java

Access host database from a docker container

From Dev

Docker - cannot access container from Mac Host

From Dev

Docker access container logs from the host machine

From Dev

Starting Vagrant VM on host boot

From Dev

Access web server on VirtualBox/Vagrant machine from host browser?

From Dev

Docker container running tomcat - could not access the server using the host IP address

From Dev

getting 'Operation not permitted' error when setting ulimit for memlock in a Docker container running ubuntu:xenial (macOS host)

From Java

Networking between KVM VM and docker container on same host

From Dev

Using Vagrant, how can I access an apache virtual host from the host OS's web browser

From Dev

Link docker container with host

From Dev

Ubuntu host. Windows XP VM. Internet Access for VM via host

From Dev

Multiple Monitors while running Ubuntu on VM Ware, with Windows Host

Related Related

  1. 1

    Access docker container running in coreos on vagrant vm through browser in host ubuntu host

  2. 2

    Run docker container on Linux VM which is running on Linux host system

  3. 3

    Access Web UI running in docker container running on remote host

  4. 4

    Accessing web application running inside a docker container in host browser?

  5. 5

    Access VM with SSH through VM host

  6. 6

    How to access mysql running in docker container from host machine?

  7. 7

    Running docker on Ubuntu: mounted host volume is not writable from container

  8. 8

    Docker: copy data from host to mounted host directory to access it from the running container

  9. 9

    Docker: copy data from host to mounted host directory to access it from the running container

  10. 10

    Using rsync on windows with vagrant running a CoreOS VM

  11. 11

    Running a Docker container that accept traffic from the host

  12. 12

    Running GUI apps on docker container with a MacBookPro host

  13. 13

    Running GUI apps on docker container with a MacBookPro host

  14. 14

    Running as a host user within a Docker container

  15. 15

    Slow network access to vagrant VM when host connected to wifi

  16. 16

    Cannot access Elasticsearch 2.0 in Vagrant VM from host OS

  17. 17

    How to access host port from docker container

  18. 18

    Access host database from a docker container

  19. 19

    Docker - cannot access container from Mac Host

  20. 20

    Docker access container logs from the host machine

  21. 21

    Starting Vagrant VM on host boot

  22. 22

    Access web server on VirtualBox/Vagrant machine from host browser?

  23. 23

    Docker container running tomcat - could not access the server using the host IP address

  24. 24

    getting 'Operation not permitted' error when setting ulimit for memlock in a Docker container running ubuntu:xenial (macOS host)

  25. 25

    Networking between KVM VM and docker container on same host

  26. 26

    Using Vagrant, how can I access an apache virtual host from the host OS's web browser

  27. 27

    Link docker container with host

  28. 28

    Ubuntu host. Windows XP VM. Internet Access for VM via host

  29. 29

    Multiple Monitors while running Ubuntu on VM Ware, with Windows Host

HotTag

Archive