日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Ubuntu >内容正文

Ubuntu

记录一次wls2上ubuntu20.04版本中安装docker

發布時間:2023/12/20 Ubuntu 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 记录一次wls2上ubuntu20.04版本中安装docker 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

為了方便使用docker容器演示,在win10上安裝了wls2以及ubuntu20.04系統

1、配置阿里云源

更換apt源并修改DNS解析

  • 更換apt源
  • 修改DNS
  • cat /etc/resolv.conf # This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf: # [network] # generateResolvConf = false nameserver 10.18.104.246 nameserver 61.178.0.93 nameserver 192.168.6.200

    2、配置root秘密并開啟遠程登錄

  • 配置密碼
  • sudo su passwd root
  • 開啟遠程登錄
  • vim /etc/ssh/sshd_config # 配置一下選項 Port 22 #AddressFamily any ListenAddress 0.0.0.0#PermitRootLogin prohibit-password PermitRootLogin yesPasswordAuthentication yes# 安裝ssh服務 apt-get install openssh-server openssh-client/etc/init.d/ssh startifconfig

    即可使用遠程工具進行連接

    3、安裝docker

    wget https://download.docker.com/linux/ubuntu/gpg sudo apt-key add gpgcurl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun


    修改service

    遠程docker server開啟了tcp連接,即在 /lib/systemd/system/docker.service 中的ExecStart=/usr/bin/dockerd 一句后面追加tcp訪問協議,如下

    [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 unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 ExecReload=/bin/kill -s HUP $MAINPID

    4、重啟wls的ubuntu

    # 管理員運行powershell Get-Service LxssManager | Restart-Service# 啟動sshd /etc/init.d/ssh start # 啟動docker service docker start service docker status

    5、曲線救國

    wls中啟動docker可能會遇到各種問題,這時候我們可以考慮曲線救國的方式,那么多容器化工具,podman、containerd等,為什么非要使用docker呢
    這里使用podman代替docker(目的是為了方便容器化操作)

    # 卸載上一步安裝的 dpkg --get-selections | grep -v deinstall | grep docker | awk '{print $1}' docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin docker-scan-plugin# 刪除查詢到的docker被安裝的信息后刪除 sudo apt-get autoremove docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin docker-scan-plugin -y

    安裝podman

    # 執行以下命令導出' /etc/os-release '文件中的環境變量。 . /etc/os-release# 添加具有穩定版本的 podman 存儲庫,并使用以下命令將 GPG 密鑰添加到您的系統。 echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.listcurl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key" | sudo apt-key add -# 更新/刷新 Ubuntu 存儲庫并將所有軟件包升級到最新版本。 sudo apt update sudo apt -y upgrade# 安裝 sudo apt install podman -ypodman version# 添加別名(騙騙自己,假裝使用的是docker) sudo vim /root/.bashrc vim .bashrc # 添加別名 alias docker='podman'source .bashrc# 測試 sudo docker version sudo docker info

    參考鏈接:
    https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b11YfnocC
    https://blog.51cto.com/wdndltg/5189597
    https://blog.csdn.net/bean_business/article/details/112278504
    https://blog.csdn.net/XhyEax/article/details/105560377
    https://www.jianshu.com/p/95742c89a3ba
    https://zhuanlan.zhihu.com/p/457866408
    https://www.cnblogs.com/it-tsz/p/11107510.html
    https://geray-zsg.github.io/2022/01/Docker%E5%9F%BA%E7%A1%80/

    總結

    以上是生活随笔為你收集整理的记录一次wls2上ubuntu20.04版本中安装docker的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。