Last active
November 16, 2020 15:54
-
-
Save caliburn1994/f249757690c6e951812844f4b00e26fc to your computer and use it in GitHub Desktop.
install Docker in Vagrant Centos 7 2020-10-07
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# 2020-10-07 | |
# install required package | |
sudo yum install -y yum-utils \ | |
device-mapper-persistent-data \ | |
lvm2 | |
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo | |
yum makecache fast | |
# install and start docker | |
# yum install -y docker-ce docker-ce-cli containerd.io | |
systemctl enable docker | |
systemctl start docker | |
# add the current user to docker group | |
# https://docs.docker.com/engine/install/linux-postinstall/ | |
sudo groupadd docker | |
sudo usermod -aG docker $USER | |
# install docker-compose | |
# https://docs.docker.com/compose/install/ | |
curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
chmod +x /usr/local/bin/docker-compose | |
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose | |
# Command-line completion | |
# https://docs.docker.com/compose/completion/ | |
yum install bash-completion bash-completion-extras | |
curl -L https://raw.githubusercontent.com/docker/compose/1.27.4/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose | |
# other tools | |
yum install -y vim | |
yum install -y net-tools | |
# timezone | |
timedatectl set-timezone Asia/Tokyo | |
yum install -y ntpdate | |
# expose docker to tcp://127.0.0.1:2375 | |
# https://docs.docker.com/engine/install/linux-postinstall/ | |
tee /usr/lib/systemd/system/docker.service <<-'EOF' | |
[Service] | |
ExecStart= | |
ExecStart=/usr/bin/dockerd -H unix:// -H tcp://127.0.0.1:2375 | |
EOF | |
systemctl daemon-reload | |
# restart | |
reboot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant.configure("2") do |config| | |
config.vm.box = "centos/7" | |
# config.vm.network "public_network", ip: "192.168.0.180",bridge:"ens33" | |
config.vm.provision :shell, path: "bootstrap.sh" | |
config.vm.provision "shell",run: "always", inline: <<-SHELL | |
ntpdate asia.pool.ntp.org | |
SHELL | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment