首页 > 其他分享 >ansible 二进制安装docker

ansible 二进制安装docker

时间:2022-09-28 15:25:54浏览次数:63  
标签:systemd name 二进制 ansible usr docker copy data

 

首先,上传文件docker-20.10.9.tgz 到/data/docker/下

 

1、编辑docker.service文件

docker的配置文件

vim /data/docker/docker.service

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker

Environment=PATH=/usr/local/docker:/usr/bin:/usr/sbin
ExecStart=/usr/local/docker/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

2、编辑/data/docker/daemon.json文件

用来修改docker容器的存放位置

vim /data/docker/daemon.json

{"data-root": "/data/docker/data"}

3、编辑docker.yml文件

vim docker.yml

---
- hosts: s104
  remote_user: root

  tasks:
    - name: mkdir
      file: name=/data/docker state=directory
    - name: copy tar
      copy: src=/data/docker/docker-20.10.9.tgz dest=/data/docker/
    - name: tar
      unarchive: src=/data/docker/docker-20.10.9.tgz dest=/usr/local/ copy=no
    - name: copy conf
      copy: src=/data/docker/docker.service dest=/etc/systemd/system/
    - name: edit profile
      ineinfile: name=/etc/profile line="export PATH=$PATH:/usr/local/docker"
    - name: source profile
      shell: source /etc/profile
    - name: reload
      shell: systemctl daemon-reload
    - name: start docker
      service: name=docker state=started
    - name: copy json
      copy: src=/data/docker/daemon.json dest=/etc/docker/
    - name: reload2
      shell: systemctl daemon-reload
    - name: restart docker
      service: name=docker state=restarted

4、验证

   ansible-playbook docker.yml

 

 被控端192.168.59.104 成功安装上docker

标签:systemd,name,二进制,ansible,usr,docker,copy,data
From: https://www.cnblogs.com/leihongnu/p/16738178.html

相关文章

  • prometheus export 各种服务 docker-compose文件
    redis-exporter配置docker-composeversion:'3'services:redis-exporter:image:oliver006/redis_exporterrestart:alwayscommand:-'--redis......
  • k8s集群上 docker 镜像编译
    因工作需要,在k8s集群上程序构建镜像。调研了dockerindocker方案。见链接。https://applatix.com/case-docker-docker-kubernetes-part-2/怎么都感觉不够智能,而且有点......
  • docker配置阿里云加速器(修改daemon.json后缀为conf)
    问题:docker无法拉取镜像,根据网上教程添加 /etc/docker/daemon.json后仍然失败。解决方法:将daemon.json文件名改为daemon.conf 后成功解决问题。网上常见配置方......
  • Docker常用命令及参数
    1、https://baijiahao.baidu.com/s?id=1692361731135557712&wfr=spider&for=pcDocker是一个被广泛使用的开源容器引擎,是一种操作系统级别的虚拟化技术,它以一种特殊进程......
  • docker 安装 redis
    1、启动镜像dockerrun--restart=always--log-optmax-size=100m--log-optmax-file=2-p6379:6379--namemyredis-v/opt/myredis/redis.conf:/etc/redis/redis.co......
  • 什么是docker swarm configs?及其在service中的使用?
    今天,来说一个在service中非常高级的知识点,configs. 然后,通过一些示例,来一步一步的演示,如何在service中使用,有什么关键的注意事项。什么是configs? configs的准确说......
  • ansible register
    目录ansibleregister实例1ansibleregisteransibleregister这个功能非常有用。当我们需要判断对执行了某个操作或者某个命令后,如何做相应的响应处理(执行其他ansible......
  • docker 安装
    #!/bin/bash#删除已安装的Dockersudoyum-yremovedocker\docker-client\docker-client-latest\doc......
  • ansible template
    目录ansibletemplatetemplate介绍实例实例1实例2实例3实例4ansibletemplatetemplate介绍Jinja是基于Python的模板引擎。template类是Jinja的另一个重要组件,可以看作一......
  • docker部署、运行tomcat问题
    1.dockertomcat拉取进入dockerHub选取自己需要的tomcat版本。docker拉取命令dockerpulltomcat:tagtag为选择的版本号2.tomcat启动dockerrun-d--nametomcat01......