I
I
Intelide2017-03-04 08:29:48
linux
Intelide, 2017-03-04 08:29:48

How to run docker in virtualbox?

Hello, can anyone come across this, when trying to run kitematic in virtualbox on debian, the error
"we couln't find a native setup. Click the virtualbox button to use virtualbox instead or retry to check agian"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yeah, 2017-03-09
@Yeah

I used docker-compose and the corresponding vagrant plugin for this.
First do vagrant plugin install vagrant-docker-compose
Then Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "debian/jessie64"

  config.vm.synced_folder "./", "/vagrant", type: "nfs"

  config.vm.provider "virtualbox" do |vb|
    vb.memory = "2048"
  end

  config.vm.network :private_network, ip: "192.168.88.88"
  config.vm.network :forwarded_port, guest: 22, host: 2388
  config.vm.network :forwarded_port, guest: 2375, host: 2375
  config.vm.network :forwarded_port, guest: 2376, host: 2376

  config.vm.provision "shell", inline: <<-SHELL
    mkdir -p /etc/systemd/system/docker.service.d
    echo "[Service]" > /etc/systemd/system/docker.service.d/docker.conf
    echo "ExecStart=" >> /etc/systemd/system/docker.service.d/docker.conf
    echo "ExecStart=/usr/bin/dockerd -H 0.0.0.0:2375" >> /etc/systemd/system/docker.service.d/docker.conf
  SHELL
  config.vm.provision :docker
  config.vm.provision :docker_compose, yml: "/vagrant/docker-compose.yml", run: "always", rebuild: true,
    options: "-H tcp://0.0.0.0:2375"
end

And finally docker-compose.yml:
version: '2'
services:
  php:
    container_name: php7
    image: php:7.0-fpm-alpine
    ports:
      - "9000:9000"
    links:
      - db
    volumes:
      - /var/www/:/var/www/

  web:
    container_name: web
    image: nginx:latest
    ports:
      - "80:80"
      - "443:443"
    links:
      - php
      - adminer
    volumes:
      - ./environment/${ENV}/nginx:/etc/nginx/conf.d
      - /var/www/:/var/www/

  db:
    container_name: db
    image: mysql:5.6
    ports:
      - "3306:3306"
    volumes:
      - ./environment/${ENV}/mysql/data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_DATABASE=${MYSQL_DATABASE}

  adminer:
    image: adminer:fastcgi
    container_name: adminer
    links:
      - db

vagrant up - voila, everything works

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question