Docker + Docker Compose on Vagrant Ubuntu Server
- Downloads – Oracle VM VirtualBox
- Downloads | Vagrant by HashiCorp
- Vagrant box ubuntu/bionic64 - Vagrant Cloud
- Install Docker Engine on Ubuntu | Docker Documentation
- Install Docker Compose | Docker Documentation
kvm (qemu)を使うこともできるらしいが、対応したboxを用意する必要があるのでVirtualBoxを使う。
Commands
# 起動vagrant up# 削除vagrant destroy# sshvagrant ssh# 停止(シャットダウン)vagrant halt
Vagrantfile
# -*- mode: ruby -*-# vi: set ft=ruby :Vagrant.configure("2") do |config|config.vm.box = "ubuntu/bionic64"config.vm.hostname = "ubuntu-docker"# config.vm.network "forwarded_port", guest: 80, host: 8080# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"config.vm.provider "virtualbox" do |vb|vb.name = "ubuntu-docker"vb.memory = "1024"# vb.gui = trueendconfig.vm.provision "shell", inline: <<-SHELLapt-get updateapt-get install -y \apt-transport-https \ca-certificates \curl \gnupg-agent \software-properties-commoncurl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -add-apt-repository -y \"deb [arch=amd64] https://download.docker.com/linux/ubuntu \$(lsb_release -cs) \stable"apt-get updateapt-get install -y \docker-ce \docker-ce-cli \containerd.iocurl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-composechmod +x /usr/local/bin/docker-composeadduser vagrant dockerSHELLend