docker

set up docker and run httpd in 2 vagrant machines. 1

More than 1 year has passed since last update.

overview

Macに2台のvagrant machineを用意して、1台でhttpdのimageを作成して、もう1台でそれを利用してhttpdを起動させたいと思います。

docker1.png

  1. set up docker in vagrant_1
  2. docker pull
  3. docker run
  4. docker push
  5. set up vagrant_2
  6. set up docker in vagrant_2
  7. docker pull
  8. docker run

Set up Vagrant machine and centOS7

in your local Mac.

bash
vagrant box add centos7_2 https://github.com/CommanderK5/packer-centos-template/releases/download/0.7.2/vagrant-centos-7.2.box
bash
mkdir docker_1
bash
cd docker_1
bash
vagrant init centos7_2
bash
vi Vagrantfile

Change IP address

Vagrantfile
config.vm.network "private_network", ip: "192.168.55.44"
bash
vagrant up

Login to virtual machine

bash
vagrant ssh

Set up docker in CentOS7

check linux version

bash
cat /etc/redhat-release
#CentOS Linux release 7.2.1511 (Core)

yum update

bash
sudo yum -y update
bash
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
bash
sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
bash
sudo yum-config-manager --enable docker-ce-edge
bash
sudo yum-config-manager --enable docker-ce-testing
bash
sudo yum makecache fast
bash
sudo yum install -y docker-ce
bash
sudo systemctl start docker
bash
sudo docker run hello-world
b04784fba78d: Pull complete 
Digest: sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

続きはこちら