Я для этого использовал docker-compose и соответствующий плагин для vagrant.
Сначала делаем vagrant plugin install vagrant-docker-compose
Потом 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
И наконец 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 - вуаля, все работает