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

  • marathon instances are not running
  • Test automation with docker, travis and a large database
  • Docker-compose mounts are going to work with TCP host?
  • Dynamically get a running container name created by docker-compose
  • Get command used to start a Docker container
  • dockerize does not delay the container initialization
  • 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.

  • How to use gcloud preview app run without boot2docker? [duplicate]
  • Docker not installing composer dependencies after image built
  • docker info: are huge (tens-of-thousands) container counts normal?
  • Docker | How to build and deploy war file in jboss container hosted in Docker
  • how to cache post requests with varnish?
  • How to customize the docker run command on Elastic Beanstalk?
  • 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.