ubuntu18.04安装docker 并修改其默认路径

ubuntu18.04安装docker 并修改其默认路径

0 删除已有docker

sudo apt-get remove docker docker-engine docker.io containerd runc

1 使用 Docker 仓库进行docker安装

两个方法可以较差借鉴用

方法一(实测成功):

参考链接:https://www.runoob.com/docker/ubuntu-docker-install.html

# 更新 apt 包索引
sudo apt-get install \apt-transport-https \ca-certificates \curl \gnupg-agent \software-properties-common# 添加 Docker 的官方 GPG 密钥
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -# 验证您现在是否拥有带有指纹的密钥
sudo apt-key fingerprint 0EBFCD88# 使用以下指令设置稳定版仓库
sudo add-apt-repository \"deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \$(lsb_release -cs) \stable"# 更新 apt 包索引
sudo apt-get update# 安装最新版本的 Docker Engine-Community 和 containerd 
sudo apt-get install docker-ce docker-ce-cli containerd.io# 测试 Docker 是否安装成功,输入以下指令,打印出以下信息则安装成功:
sudo docker run hello-worldUnable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete                                                                                                                                  Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
Status: Downloaded newer image for hello-world:latestHello from Docker!
This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the "hello-world" image from the Docker Hub.(amd64)3. The Docker daemon created a new container from that image which runs theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/get-started/

方法二(官方版本):

参考链接:https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg# Add the repository to Apt sources:
echo \"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update# Install the Docker packages
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin# 测试 Docker 是否安装成功,输入以下指令,打印出以下信息则安装成功:
sudo docker run hello-worldUnable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete                                                                                                                                  Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
Status: Downloaded newer image for hello-world:latestHello from Docker!
This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the "hello-world" image from the Docker Hub.(amd64)3. The Docker daemon created a new container from that image which runs theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/get-started/

2 修改默认路径

# 确认当前的docker存储位置
docker info# 停止docker服务
systemctl stop docker# 停止docker服务
systemctl stop docker# 创建drop-in目录和drop-in文件
mkdir /etc/systemd/system/docker.service.d
touch /etc/systemd/system/docker.service.d/docker.conf
echo "[Service]">>/etc/systemd/system/docker.service.d/docker.conf
echo "ExecStart=">>/etc/systemd/system/docker.service.d/docker.conf
echo "ExecStart=/usr/bin/dockerd --data-root="/mnt/data/docker" --storage-driver=overlay2">>/etc/systemd/system/docker.service.d/docker.conf
# /mnt/data/docker是新的存储位置,而overlay2是当前docker所使用的存储驱动。# 重新加载服务守护程序和启动docker服务
systemctl daemon-reload
systemctl start docker# 修改结果确认
docker info
# 检查Server下的Docker Root Dir标记,显示的路径应该是新的docker镜像和容器存储位置,如本例的/mnt/data/docker。

注:

在 docker 19.xx 版本以后使用 data-root 来代替 graph 可以在 /etc/docker/daemon.json 中配置,也可以在 docker.service 中修改,效果一样。修改完成后 daemon-reload 一下然后 restart docker

参考链接

  • https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository

  • https://www.runoob.com/docker/ubuntu-docker-install.html

  • https://blog.csdn.net/u010227042/article/details/129472825?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_baidulandingword~default-0-129472825-blog-108221250.235v38pc_relevant_sort_base3&spm=1001.2101.3001.4242.1&utm_relevant_index=3

  • https://blog.csdn.net/a772304419/article/details/121244400

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/773868.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

文件路径中的 ./ 和 ../ 和 / 的区别

路径中的“./”、“../”和“/”分别代表以下含义: “./”:代表当前所在的目录。在路径中使用它,表示你正在引用当前目录下的一个文件或子目录。“../”:代表上一层目录。当你在路径中使用“../”,你正在引用当前目录…

Web API —— DOM 学习(四)(完结)

目录 一、日期对象 (一)实例化 (二)日期对象方法 1.时间戳介绍 2.获得时间戳的方式 getTime()方法 new Date()方法 Date.now()方法 二、节点操作 (一)DOM 节点 1.节点类型 元素节点 &#xff08…

1+x中级题目练习复盘(20220625 1+X 中级理论考试)

Override 用于标注重写方法 函数式接口是指有且只有一个抽象方法的接口;

vue项目使用eletron将打包成桌面应用(.exe)

vue项目使用eletron将打包成桌面应用(.exe) 1.前期准备 两个项目: 1、自己用vue cli创建的项目 2、第二个是去gitee将案例clone下来 案例地址 https://gitee.com/qingplus/electron-quick-start.git 2、测试案例是否可以正常运行 # 进入项目 cd electron-quick-…

任务管理工具Trello体验如何?一文揭秘

Trello是一款高效的协作与工作管理应用,这里我们将详细介绍Trello的功能、特点、优劣势、价格、定价、发展历程、使用场景以及使用技巧等等。 一、Trello 是什么 Trello是一款高效的协作与工作管理应用,设计用于跟踪团队项目、凸显当前活动任务、指派责…

索引器(indexer)demo

1.索引器允许类或者结构的实例按照与数组相同的方式进行索引。 索引器类似于属性,不同之处在于他们的访问采用参数。 2.索引器必须以this关键字定义,这个this代表类实例化后的对象,如下定义一个类的索引器实例: public class IDXer …

POJ3037 + HDU-6714

两道最短路好题 POJ3037 手玩一下 发现每一点的速度可以直接搞出来&#xff0c;就是pow(2,h[1][1]-h[i][j])*V 那么从这个点出发到达别的点的耗费的时间都是上面这个数的倒数&#xff0c;然后直接跑最短路就好了 #include<iostream> #include<vector> #include<…

某头部券商企业:朗思Agent 数字员工上岗,提质增效,释放人力

在数字化转型背景下&#xff0c;越来越多证券企业积极探索数字员工在运营管理和业务经营中的应用&#xff0c;全面提升服务效能&#xff0c;推进数智化建设&#xff0c;以应对行业内的诸多挑战。 某券商企业加强数字赋能&#xff0c;积极部署数字员工&#xff0c;仅财务中心工…

赛氪网积极参与千校万企协同创新行动,推动产学研深度融合

3月17日&#xff0c;中国千校万企协同创新推进会在北京盛大召开&#xff0c;会议旨在实现高校与行业龙头企业技术升级需求的精准对接&#xff0c;加速新质生产力的形成与发展。教育部党组成员、副部长孙尧&#xff0c;科技部成果转化司副司长秦浩源&#xff0c;国家知识产权局知…

王者荣耀国服米莱迪 - 出装打法详细教学视频(最新)

01. 恰到好处的一技能 02. 灵魂二技能 03. 无敌大招连招 04. 为所欲为的出装 05. 拥有这个召唤师技能赢一半 06. 英雄克制 07. 整局精讲 08. 米莱迪最强出装 09. 米莱迪最强出装的铭文 发送内容: "米莱迪", 获取提取码

unity 2d范围检测:怪物检测范围

需求 实现怪物有一定范围的侦测能力&#xff0c;当目标进入侦测范围内后&#xff0c;自动追踪目标[使用unity navmash实现]&#xff0c;当子弹进入时&#xff0c;销毁子弹&#xff0c;播放怪物死亡动画以及其他事件。 实现方案 实现怪物在主角靠近一定范围内时发动攻击的功能…

智慧楼宇一体可视化管理平台方案

现状分析 考勤问题 传统IC卡考勤存在漏洞,无法避免人员代刷卡的问题传统IC卡需要成本,丢失后容易造成公司财产安全隐患,而且补卡麻烦大楼内未部署人脸识别系统,无法实现工作人员的人脸无感考勤对黑名单人员无法进行管控;空间管理问题 工位管理大楼办公区工位较多,管理者无…

【Java程序设计】【C00383】基于(JavaWeb)Springboot的水产养殖系统(有论文)

【C00383】基于&#xff08;JavaWeb&#xff09;Springboot的水产养殖系统&#xff08;有论文&#xff09; 项目简介项目获取开发环境项目技术运行截图 博主介绍&#xff1a;java高级开发&#xff0c;从事互联网行业六年&#xff0c;已经做了六年的毕业设计程序开发&#xff0c…

阿里云ECS选型推荐配置

本文介绍构建Kubernetes集群时该如何选择ECS类型以及选型的注意事项。 集群规格规划 目前在创建Kubernetes集群时&#xff0c;存在着使用很多小规格ECS的现象&#xff0c;这样做有以下弊端&#xff1a; 网络问题&#xff1a;小规格Worker ECS的网络资源受限。 容量问题&…

推荐多样性 - 华为OD统一考试(C卷)

OD统一考试(C卷) 分值: 200分 题解: Java / Python / C++ 题目描述 推荐多样性需要从多个列表中选择元素,一次性要返回N屏数据(窗口数量),每屏展示K个元素(窗口大小),选择策略: 各个列表元素需要做穿插处理,即先从第一个列表中为每屏选择一个元素,再从第二个列表…

BRICK POP展示了有趣的链上游戏玩法与奖励机制

新游戏BRICK POP将Sui区块链技术与低Gas费用&#xff0c;以及其在Web3游戏开发方面的专业知识无缝结合。通过充分利用Sui和ONBUFF的INNO平台优势&#xff0c;BRICK POP为玩家提供了一个融合了前沿技术和引人入胜游戏的沉浸式游戏体验。BRICK POP游戏设计为实时交易和高用户参与…

Mybatis-01

Mybatis >Mybatis是什么? MyBatis 是一款优秀的持久层框架&#xff0c;它支持 SQL、存储过程以及高级映射。 >Mybatis的三种使用方式 ① sqlSession执行对应语句&#xff08;不推荐&#xff09; ② 利用注解 &#xff08;只适用于较短的sql语句&#xff09; ③ 接…

大数据开发(日志离线分析项目)

大数据开发&#xff08;日志离线分析项目&#xff09; 一、项目需求1、使用jqueryecharts的方式调用程序后台提供的rest api接口&#xff0c;获取json数据&#xff0c;然后通过jquerycss的方式进行数据展示。工作流程如下&#xff1a;2、七大角度1、用户基本信息分析模块2、浏览…

【Python】学习率调整策略详解和示例

学习率调整得当将有助于算法快速收敛和获取全局最优&#xff0c;以获得更好的性能。本文对学习率调度器进行示例介绍。 学习率调整的意义基础示例无学习率调整方法学习率调整方法一多因子调度器余弦调度器 结论 学习率调整的意义 首先&#xff0c;学习率的大小很重要。如果它…

java 面向对象入门

类的创建 右键点击对应的包&#xff0c;点击新建选择java类 填写名称一般是名词&#xff0c;要知道大概是什么的名称&#xff0c;首字母一般大写 下面是创建了一个Goods类&#xff0c;里面的成员变量有&#xff1a;1.编号&#xff08;id&#xff09;&#xff0c;2.名称&#x…