Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Docker automatically with one button

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to install Docker automatically with one click. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

1) create a virtual machine

Prepare scripts to automate the creation of VM

The Ansible script that checkout uses to create KVM Guest. Cd ~ / devenv_bootstrap/

Git clone git@github.com:dhyuan/virt-infra-ansible.git

Cd ~ / devenv_bootstrap/virt-infra-ansible/roles

Git clone https://github.com/dhyuan/ansible-role-virt-infra.git

Cd ansible-role-virt-infra

Git checkout-b devenv

Git branch-set-upstream-to origin/devenv

Git pull

Modify the virtual machine parameter vi ~ / devenv_bootstrap/virt-infra-ansible/k8s_masters.yml defined in inventory based on your own situation

Vi ~ / devenv_bootstrap/virt-infra-ansible/k8s_nodes.yml

If we want to use DHCP services to make these machines have a fixed IP, then we can set the mac address for the virtual machine here.

Create a virtual machine ansible-playbook. / virt-infra.yml\

-- limit kvmhost,k8s_masters,k8s_nodes

Start the virtual machine ansible-playbook. / virt-infra.yml\

-- limit kvmhost,k8s_masters,k8s_nodes\

-- extra-vars virt_infra_state=running

Stop the virtual machine ansible-playbook. / virt-infra.yml\

-- limit kvmhost,k8s_masters,k8s_nodes\

-- extra-vars virt_infra_state=shutdown

Delete a virtual machine

It is strongly recommended that you use ansible to delete virtual machines because the hosts file on KVM HOST and some configurations of ssh also need to be modified.

Ansible-playbook. / virt-infra.yml\

-- limit kvmhost,k8s_masters,k8s_nodes\

-- extra-vars virt_infra_state=undefined

Update virtual machine ansible-playbook-- ask-become-pass-- inventory. / inventory ansible/update-vms.yaml

2) when the virtual machine is ready, install docker. Install docker roleansible-galaxy install\ on KVMHost

-roles-path ~ / .ansible/roles/\

Git+ https://github.com/haxorof/ansible-role-docker-ce.git,2.7.0

#

Ansible-galaxy list

Its code is saved in ~ / .ansible / roles/ansible-role-docker-ce

Create a playbook that installs docker

You can see that the domestic docker mirror source is used here to improve the download speed. For a private cloud environment, you can set it to your own internal mirror library address.

[devops@192 virt-infra-ansible] $cat install_docker.yml

-

-hosts: all.cmhost

Vars:

Docker_version: 19.03.8

Docker_remove_pre_ce: false

Docker_users: [devops]

Docker_daemon_config:

Registry-mirrors:

[

"http://ovfftd6p.mirror.aliyuncs.com",

"http://registry.docker-cn.com",

"http://docker.mirrors.ustc.edu.cn",

"http://hub-mirror.c.163.com",

]

Insecure-registries: ["docker.mirrors.ustc.edu.cn"]

Roles:

-role: ansible-role-docker-ce

[devops@192 virt-infra-ansible] $

Install docker engine on all K8s nodes.

The focus here is on the use of domestic ali docker-ce sources.

Ansible-playbook. / install_docker.yml\

-- limit k8smakers mastersjiggery k8scrafts-v\

-e'{"docker_repository_url": {"CentOS": "http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo"}}'

Log in to the master, nodes node to confirm that docker is installed successfully. Thank you for reading! This is the end of the article on "how to automatically install Docker with one click". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report