首页 > 其他分享 >ubantu docker

ubantu docker

时间:2023-04-03 10:12:56浏览次数:36  
标签:systemd ubantu service containerd systemctl && docker

 

docker.service

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

[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
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# 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

# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity

# 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

[Install]
WantedBy=multi-user.target

 

containerd.service

[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target

[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd

Type=notify
Delegate=yes
KillMode=process
Restart=always
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=1048576
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity

[Install]
WantedBy=multi-user.target

 

 

limits.conf

*             soft    core            unlimited
*             hard    core            unlimited
*	      soft    nproc           1000000
*             hard    nproc           1000000
*             soft    nofile          1000000
*             hard    nofile          1000000
*             soft    memlock         32000
*             hard    memlock         32000
*             soft    msgqueue        8192000
*             hard    msgqueue        8192000

  

sysctl.conf

net.ipv4.ip_forward=1
vm.max_map_count=262144
kernel.pid_max=4194303
fs.file-max=1000000
net.ipv4.tcp_max_tw_buckets=6000
net.netfilter.nf_conntrack_max=2097152

net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
vm.swappiness=0

 

install docker

#!/bin/bash
DIR=`pwd`
PACKAGE_NAME="docker-19.03.15.tgz"
DOCKER_FILE=${DIR}/${PACKAGE_NAME}
centos_install_docker(){
  grep "Kernel" /etc/issue &> /dev/null
  if [ $? -eq 0 ];then
    /bin/echo  "当前系统是`cat /etc/redhat-release`,即将开始系统初始化、配置docker-compose与安装docker" && sleep 1
    systemctl stop firewalld && systemctl disable firewalld && echo "防火墙已关闭" && sleep 1
    systemctl stop NetworkManager && systemctl disable NetworkManager && echo "NetworkManager" && sleep 1
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux && setenforce  0 && echo "selinux 已关闭" && sleep 1
    \cp ${DIR}/limits.conf /etc/security/limits.conf 
    \cp ${DIR}/sysctl.conf /etc/sysctl.conf

    /bin/tar xvf ${DOCKER_FILE}
    \cp docker/*  /usr/bin

    \cp containerd.service /lib/systemd/system/containerd.service
    \cp docker.service  /lib/systemd/system/docker.service
    \cp docker.socket /lib/systemd/system/docker.socket

    \cp ${DIR}/docker-compose-Linux-x86_64_1.24.1 /usr/bin/docker-compose
    
    groupadd docker && useradd docker -g docker
    id -u  magedu &> /dev/null
    if [ $? -ne 0 ];then
      useradd magedu
      usermod magedu -G docker
    fi
    systemctl  enable containerd.service && systemctl  restart containerd.service
    systemctl  enable docker.service && systemctl  restart docker.service
    systemctl  enable docker.socket && systemctl  restart docker.socket 
  fi
}

ubuntu_install_docker(){
  grep "Ubuntu" /etc/issue &> /dev/null
  if [ $? -eq 0 ];then
    /bin/echo  "当前系统是`cat /etc/issue`,即将开始系统初始化、配置docker-compose与安装docker" && sleep 1
    \cp ${DIR}/limits.conf /etc/security/limits.conf
    \cp ${DIR}/sysctl.conf /etc/sysctl.conf
    
    /bin/tar xvf ${DOCKER_FILE}
    \cp docker/*  /usr/bin 

    \cp containerd.service /lib/systemd/system/containerd.service
    \cp docker.service  /lib/systemd/system/docker.service
    \cp docker.socket /lib/systemd/system/docker.socket

    \cp ${DIR}/docker-compose-Linux-x86_64_1.24.1 /usr/bin/docker-compose
    ulimit  -n 1000000 
    /bin/su -c -  jack "ulimit -n 1000000"
    /bin/echo "docker 安装完成!" && sleep 1
    id -u  magedu &> /dev/null
    if [ $? -ne 0 ];then
      groupadd  -r magedu
      groupadd  -r docker
      useradd -r -m -g magedu magedu
      usermod magedu -G docker
    fi  
    systemctl  enable containerd.service && systemctl  restart containerd.service
    systemctl  enable docker.service && systemctl  restart docker.service
    systemctl  enable docker.socket && systemctl  restart docker.socket 
  fi
}

main(){
  centos_install_docker  
  ubuntu_install_docker
}

main

 

标签:systemd,ubantu,service,containerd,systemctl,&&,docker
From: https://www.cnblogs.com/gaoyuechen/p/17282247.html

相关文章

  • docker mysql
    -eMYSQL_ROOT_PASSWORD=my-secret-pw-v/my/custom:/etc/mysql/conf.ddockerrun-it--rmmysql:tag--verbose--helpdockerrun--namesome-mysql-v/my/own/datadir:/var/lib/mysql-eMYSQL_ROOT_PASSWORD=123456-dmysql:tagdockerrun--namesome-mysql-e......
  • Docker - 安装Redis
    目录前言环境安装Redis下载Redis安装Redis配置Redis前言记录下Docker下Redis的安装环境Centos7+Docker23.0.1+Redis6.2.7安装Redis下载Redis指定版本下载redis,版本可通过仓库https://hub.docker.com查看dockerpullredis:6.2.7安装Redis创建redis配置......
  • Docker - 常用命令参考
    目录Docker命令关系图常用命令脑图docker命令大全参考Docker命令关系图常用命令脑图docker命令大全参考$docker--help用法:......
  • Docker - 安装Mysql
    目录前言环境安装Mysql下载Mysql安装Mysql配置Mysql前言记录下Docker下Mysql的安装环境Centos7+Docker23.0.1+Mysql8.0.27安装Mysql下载Mysql下载最新版mysqldockerpullmysql查看镜像列表dockerimagelsdockerimages查看镜像版本dockerimag......
  • Docker-Compose快速搭建LNMP
    Docker-Compose1.安装Dockersudoapt-yinstalldocker.iodockerversion查看版本号dockerhelp查看帮助文档2.更换镜像源sudosu-cat>>/etc/docker/daemon.json<<-EOF{"registry-mirrors":["https://mirror.ccs.tencentyun.com"]}EOFs......
  • Docker 镜像命令
    Docker镜像命令1.Dockerimages--列出本地镜像命令:dockerimages[OPTIONS][REPOSITORY[:TAG]]选项-a:列出本地所有的镜像(含中间映像层,默认情况下,过滤掉中间映像层);--digests:显示镜像的摘要信息;-f:显示满足条件的镜像;--format:指定返回值的模板文件;--no-trunc......
  • docker安装zabbix
    一、概述Zabbix是一款能够监控众多网络参数和服务器的健康度和完整性的软件。Zabbix使用灵活的通知机制,允许用户为几乎任何事件配置基于邮件的警报。这样可以快速相应服务器问题。Zabbix基于存储的数据提供出色的报告和数据可视化。这些功能使得Zabbix成为容量规划的理想选......
  • docker、compose安装及基础操作命令
    docker安装下载Docker依赖的组件yum-yinstallyum-utilsdevice-mapper-persistent-datalvm2设置下载docker服务的镜像源(阿里云)yum-config-manager--add-repohttp://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo安装docker服务yum-yinstalldocker-ce设置开机......
  • 在docker中配置Oracle11g
    在docker中配置Oracle11gdocker镜像拉取及相关配置1.在docker打开的情况下,使用下方命令拉去镜像,大概需要下载3个G的image文件dockerpullregistry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g2.启动Oracle镜像并为镜像新建容器,注意此处的oracle11g即为容器名,可以自主设置......
  • Docker镜像之Docker Compose讲解
    目录1docker-compose1.1compose编排工具简介1.2安装docker-compose1.3编排启动镜像1.4haproxy代理后端docker容器1.5安装socat直接操作socket控制haproxy1.6compose中yml配置指令参考1.6.1简单命令1.6.2build1.6.3depends_on1.6.4deploy1.6.5logging1.6.6network_m......