Install Docker on Vagrant

In this tutorial, How to install docker on Vagrant? Docker the essential for DevOps Roles.

Step by step Install Docker on Vagrant

  • Launch CentOS 7 with Vagrant
  • Install Docker on CentOS 7
  • Sharing directory with host OS and guest OS ( CentOS 7)


Vagrant must be installed. You can refer to Install Vagrant as below:

Directory Structure

The directory structure looks something like as below

- share # Directory
- Vagrantfile

The content Vagrantfile file as below

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config| = "centos/7" :private_network, type: "dhcp", ip: ""
    config.vm.synced_folder "./share", "/home/vagrant/share", type: "rsync" :forwarded_port, host: 80, guest: 80
    config.vm.provision :shell, path: "./"

Install docker on Centos 7 ( guest )

The content “” file as below

# SELinux Permissive
sudo setenforce 0
# set timezone JST
sudo timedatectl set-timezone Asia/Ho_Chi_Minh
sudo yum install -y epel-release
sudo yum install -y vim git
# install docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
sudo yum install -y yum-utils \
device-mapper-persistent-data \
sudo yum-config-manager \
--add-repo \
sudo yum install -y docker-ce
# vagrant user add docker group
sudo gpasswd -a vagrant docker
# docker running
sudo systemctl enable docker
sudo systemctl start docker

Execute vagrant command

$ cd /home/huupv/DockerHost
$ vagrant up && vagrant ssh
Video How to Install Docker using Vagrant


Thought the article, You can “install docker on Vagrant as above . I hope will this your helpful. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.