首页 > 其他分享 >docker 分离engine和client

docker 分离engine和client

时间:2023-10-30 22:26:21浏览次数:41  
标签:engine Users lanjx containerd client plugins docker cli

背景

由于我个人电脑是2020款m1,16G,256G。一方面,平时除了运行多个浏览器,还有coding 编辑器等等,内存确实很紧张。其次呢,m1 是ARM的架构,所以构建的镜像是无法在X86的机器上运行的。所以我尝试将docker引擎和client分开。

第一步:下载二进制docker 客户端文件

二进制client下载链接:传送门

如果是苹果选择aarch64,进去后选择版本(我选择的是最新版本)

第二步:安装docker

注意:

1、除了要安装docker以外,还需要开启api端口,因为客户端需要和服务端通过远程端口进行通信

2、个人安装的最新版本

3、注意开启2375端口,确保能telnet通

docker安装文档:传送门

配置远程端口:

Docker 启动文件添加-H tcp://0.0.0.0:2375

vim /usr/lib/systemd/system/docker.service
···
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service containerd.service time-set.target
Wants=network-online.target containerd.service
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
### 注意这里,我复制了一行
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375 --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutStartSec=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
···

第三步:解压并添加环境变量

解压文件后如下:

添加环境变量

注意:
使用$PATH 命令查看环境变量

# 查看环境变量
$PATH
/Users/lanjx/opt/anaconda3/bin:/Users/lanjx/.nvm/versions/node/v16.18.0/bin:....太长了,忽略
# 将图中文件解压到环境变量对应的目录中
sudo cp DownLoads/docker/docker /usr/local/sbin/
sudo chmod +x /usr/local/sbin/docker
# 添加环境变量
vim .zshrc
# 将下面一句添加到文件末尾
...
export DOCKER_HOST=tcp://192.168.0.1:2375

修改文件

vim ~/.docker/config.json
{
        "auths": {                
                 "docker.e6gpshk.com:8443": {}
        },
        "credsStore": "desktop",        
        "currentContext": "default",
  			// 添加了下面这一行
        "hosts": ["tcp://192.168.0.1:2375"]
}

第四步:测试

到这里基本上已经差不多了,剩下的就是补全剩余的组件即可

docker info
Client:
 Version:    24.0.7
 Context:    default
 Debug Mode: false
 Plugins:
WARNING: Plugin "/Users/lanjx/.docker/cli-plugins/docker-buildx" is not valid: failed to fetch metadata: fork/exec /Users/lanjx/.docker/cli-plugins/docker-buildx: no such file or directory
WARNING: Plugin "/Users/lanjx/.docker/cli-plugins/docker-compose" is not valid: failed to fetch metadata: fork/exec /Users/lanjx/.docker/cli-plugins/docker-compose: no such file or directory
WARNING: Plugin "/Users/lanjx/.docker/cli-plugins/docker-dev" is not valid: failed to fetch metadata: fork/exec /Users/lanjx/.docker/cli-plugins/docker-dev: no such file or directory
WARNING: Plugin "/Users/lanjx/.docker/cli-plugins/docker-extension" is not valid: failed to fetch metadata: fork/exec /Users/lanjx/.docker/cli-plugins/docker-extension: no such file or directory
WARNING: Plugin "/Users/lanjx/.docker/cli-plugins/docker-init" is not valid: failed to fetch metadata: fork/exec /Users/lanjx/.docker/cli-plugins/docker-init: no such file or directory
WARNING: Plugin "/Users/lanjx/.docker/cli-plugins/docker-sbom" is not valid: failed to fetch metadata: fork/exec /Users/lanjx/.docker/cli-plugins/docker-sbom: no such file or directory
WARNING: Plugin "/Users/lanjx/.docker/cli-plugins/docker-scan" is not valid: failed to fetch metadata: fork/exec /Users/lanjx/.docker/cli-plugins/docker-scan: no such file or directory
WARNING: Plugin "/Users/lanjx/.docker/cli-plugins/docker-scout" is not valid: failed to fetch metadata: fork/exec /Users/lanjx/.docker/cli-plugins/docker-scout: no such file or directory

Server:
 Containers: 2
  Running: 0
  Paused: 0
  Stopped: 2
 Images: 0
 Server Version: 24.0.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 61f9fd88f79f081d64d6fa3bb1a0dc71ec870523
 runc version: v1.1.9-0-gccaecfc
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 3.10.0-1160.80.1.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.49GiB
 Name: localhost.localdomain
 ID: 1e789c39-61f4-4269-8616-47944d1865cb
 Docker Root Dir: /data/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  https://registry.docker-cn.com/
  https://docker.mirrors.ustc.edu.cn/
 Live Restore Enabled: false

WARNING: API is accessible on http://0.0.0.0:2375 without encryption.
         Access to the remote API is equivalent to root access on the host. Refer
         to the 'Docker daemon attack surface' section in the documentation for
         more information: https://docs.docker.com/go/attack-surface/

标签:engine,Users,lanjx,containerd,client,plugins,docker,cli
From: https://www.cnblogs.com/lanheader/p/17798929.html

相关文章

  • docker与docker-compose环境安装
    系统是centos7.6离线安装docker下载docker下载地址:https://download.docker.com/linux/static/stable/x86_64/docker-20.10.21.tgz安装dockertar-xvfdocker-20.10.21.tgzcpdocker/*/usr/bin离线安装docker-compose下载docker-compose普通下载地址:do......
  • Docker_报错:Host key for 47.116.79.175 has changed and you have requested strict
    Hostkeyfor47.116.79.175haschangedandyouhaverequestedstrictchecking.Hostkeyverificationfailed. 问题原因用OpenSSH的人都知ssh会把你每个你访问过计算机的公钥(publickey)都记录在~/.ssh/known_hosts。当下次访问相同计算机时,OpenSSH会核对公钥。如果公......
  • Docker使用教程
     Docker安装及使用教程(Windows版)1.下载安装2.启用windowsHyper-V虚拟引擎1.打开设置2.搜索【启用或关闭windows功能】3.勾选Hyper-V服务4、根据提示重启电脑,等待更新即可2.启动DockerDesktop3.配置加速源4.迁移镜像路径5.进入docker虚拟机的方法6.限制虚......
  • K8s:Pod 中 command、args 与 Dockerfile 中 CMD、 ENTRYPOINT 的对应关系
    写在前面前几天被问到,这里整理笔记之前也没怎么注意这个问题理解不足小伙伴帮忙指正曾以为老去是很遥远的事,突然发现年轻是很久以前的事了。时光好不经用,抬眼已是半生,所谓的中年危机,真正让人焦虑的不是孤单、不是贫穷、更不是衰老,而是人到中年你才发现,你从来没有按照自己喜欢的方......
  • 【GEE】Google Earth Engine(GEE)注册详细教程&无需教育邮箱
    ​    这个专栏真的是纠结了很久,不知道到底要不要分享自己在学习GEE的时候的一些经验和代码。因为本人在日常中使用Python和ENVI多点,虽然GEE也会用但不至于频繁使用,同时针对GEE其实官网给出了很多接口的使用方法,国内外也有很多人分享过一些实操代码,因此大部分代码可能都......
  • 【Docker】Docker Compose服务依赖与健康检查
    dockercompose环境变量为增加安全性,在前面的python例子中增加redis的密码校验,密码从环境变量中获取:fromflaskimportFlaskfromredisimportStrictRedisimportosimportsocketapp=Flask(__name__)redis=StrictRedis(host=os.environ.get('REDIS_HOST','127.0.0.1')......
  • 【Docker】Docker数据的存储
    默认情况下,在运行中的容器里创建的文件,被保存在一个可写的容器层里,如果容器被删除了,则对应的数据也随之删除了。这个可写的容器层是和特定的容器绑定的,也就是这些数据无法方便的和其它容器共享。Docker主要提供了两种方式做数据的持久化:DataVolume:由Docker管理(数据目录/var/lib/d......
  • 【Docker】Docker的网络
    Docker提供了多种内置的网络模式,用于在容器之间建立网络连接。这些网络模式,包括桥接网络、主机网络、无网络模式。我们将主要探讨每种网络模式的优缺点、适用场景。桥接网络桥接网络是Docker的默认网络模式。在桥接网络中,Docker会为每个容器创建一个虚拟网络接口,并为容器分配一个IP......
  • 【Docker】Docker Compose的使用
    我们知道使用一个Dockerfile模板文件,可以让用户很方便的定义⼀个单独的应用容器。然而,在日常工作中,经常会碰到需要多个容器相互配合来完成某项任务的情况。例如要实现一个Web项目,除了Web服务容器本身,往往还需要再加上后端的数据库服务容器,甚至还包括负载均衡容器等,我们只能一个一个......
  • docker指令详解
    Docker指令详解1.生命周期管理run创建并运行容器,格式dockerrun[OPTIONS]image[COMMAND][ARG...],参数说明dockerrun[options]image[command][arg...]-d,--detach#后台运行-it,--interacticetty#交互终端形式运行-p,--publishlist#指定端口-v,--vo......