Accessing vagrant provider docker from vagrant virtualbox

I am running Vagrant and Virtualbox on Mac OS X. I have created one vagrant box using Virtualbox provider (some_centos machine) and second box using docker provider. Below you will see docker definition.

config.vm.define "mysql" do |m|
    m.vm.hostname = "mysql-host"
    m.vm.synced_folder ".", "/vagrant", disabled: true
    m.ssh.insert_key = false
      m.ssh.username = 'docker'
      m.ssh.password = 'tcuser'
      m.vm.network "public_network", use_dhcp_assigned_default_route: true

m.vm.provider "docker" do |docker|

  # Specify the Docker image to use
  docker.image = "mysql/mysql-server"

  # Specify port mappings
  # If omitted, no ports are mapped!

  docker.create_args = ["-p", "3306:3306","-e","MYSQL_ROOT_PASSWORD=password", "-e", "MYSQL_DATABASE=database"]

  # Specify a friendly name for the Docker container
  docker.name = 'mysql-server-container'

  #We want to keep it running.
  docker.remains_running = true
end

end

  • How can I access both ports 8080 and 9990 on bluemix single container for wildfly?
  • Access docker within container on jenkins slave
  • Private Docker Registry with Azure Storage and Nginx: 502 Bad Gateway
  • X11 forwarding of a GUI app running in docker
  • How to copy a folder from docker to other folder?
  • Using zookeeper for service discovery of mesos slaves running docker
  • Both machines do start up, but what I want to do is to access from “some_centos” host to that mysql docker machine by using mysql client to connect to it. Unfortunately I am failing. Please be aware that on Mac OS when you use vagrant docker provider it will create boot2docker iamge and then create docker. Not sure how to tackle the problem as e.g. I can ssh into “some_centos”, but can’t run mysql -h “docker-host” -uroot -p.

  • Docker does not have default machine in Windows 10
  • How to configure Vagrant box filesystem?
  • Docker running out of memory when loading large sql dump
  • unable to access mailpile server inside docker container
  • Installing packages for Rstudio Docker
  • Docker Compose Shared Folder
  • One Solution collect form web for “Accessing vagrant provider docker from vagrant virtualbox”

    I have found a workaround for this. So it looks like on MAC OS X you need also do port forwarding on that virtual machine, but manually. So you need to run following:

    VBoxManage controlvm name_of_your_virtual_machine natpf1 "mysql,tcp,,3306,,3306"

    Then I was able to do the mysql. So I will need to add this a shell provisioner to my Vagrantfile.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.