WordPress多站点默认设置,阿里云服务器一年多少钱,网站资料上传,wordpress 选择用户欢迎来到《小5讲堂》#xff0c;大家好#xff0c;我是全栈小5。 这是《Docker容器》系列文章#xff0c;每篇文章将以博主理解的角度展开讲解#xff0c; 特别是针对知识点的概念进行叙说#xff0c;大部分文章将会对这些概念进行实际例子验证#xff0c;以此达到加深对… 欢迎来到《小5讲堂》大家好我是全栈小5。 这是《Docker容器》系列文章每篇文章将以博主理解的角度展开讲解 特别是针对知识点的概念进行叙说大部分文章将会对这些概念进行实际例子验证以此达到加深对知识点的理解和掌握。 温馨提示博主能力有限理解水平有限若有不对之处望指正 目录 前言Volumes存储持久化列表创建Volume基本概念 知识点学习容器间数据 相关文章 前言
接着上篇提到的Docker Desktop目前是没有官方提供的汉化版它主要是使用英文界面。 所以本文还是接着来了解下TA界面的基本内容和信息。
Volumes存储
持久化列表
我们可以从下面描述就i可以大概了解到Volumes作用 Containers can use volumes to store data容器可以使用卷来存储数据 All data in a container lost noce it is removed.容器中的所有数据在被删除之前都会丢失 Containers use volumes to persist data.容器使用卷来持久化数据 创建Volume
输入数据持久化名称 查看列表 关联容器 docker run -d -v test_volume_data:/app/data mycorehub 自动生成了一个容器并且在对应目录下有一个文件夹app/data
添加数据 Volume界面 会自动同步显示在Volume对应的Data里所以即时容器被移除文件还会存在
基本概念
Volumes 是用于管理 Docker 容器的持久化数据存储。 在 Docker 中容器是临时性的当容器重新启动或销毁时容器内部的数据也会丢失。 但是在某些情况下我们需要保留容器中的数据以便下一次启动容器时能够继续使用。
Volumes 允许将主机文件系统中的目录或文件与容器内的目录或文件进行关联。 这样无论容器是否重新启动或销毁与之关联的数据都会被保留。 通过 Docker Desktop 的图形界面或命令行工具可以轻松创建和管理这些卷。 这为我们开发人员和运维人员提供了方便的方法来管理持久化数据并简化了与容器数据相关的操作。
值得注意的是Docker Volume 是一种独立于容器的实体并可以在多个容器之间共享和重复使用。 这使得数据在容器之间的移动和共享变得非常简单和灵活。
知识点学习
容器间数据
Persist your data between containers在容器间保持数据3分钟上手 1、Container data is isolated from your local folders Docker isolates all content, code, and data in a container from your local filesystem. This means, that when you delete a container within Docker Desktop, all the content within it is deleted. Sometimes you may want to persist data that a container generated. This is when you can use volumes. Docker将容器中的所有内容、代码和数据与本地文件系统隔离开来。这意味着当您删除Docker Desktop中的容器时其中的所有内容都会被删除。 有时您可能希望持久化容器生成的数据。此时您可以使用卷。 2、Get the sample application For this, you will be reusing the repository at https://github.com/docker/multi-container-app. git clone https://github.com/docker/multi-container-app 为此您将在重新使用存储库 3、How volumes work If you want to persist data even after a container is deleted, you can use a volume. A volume is a location in your local filesystem, managed by Docker. 如果要在删除容器后仍保留数据可以使用卷。卷是本地文件系统中的一个位置由Docker管理。 4、Adding volumes to Compose To add a volume to this project, simply go to the compose.yaml file and uncomment the following lines: todo-database:# ...volumes:- database:/data/db# ...
volumes:database:Digging deeper The volumes element that is nested in todo-database tells Compose to mount the volume named database to /data/db in the container for the todo-database service. The top-level volumes element defines and configures a volume named database that can be used by any of the services in the Compose file. 要向该项目添加卷只需转到compose.yaml文件并取消注释以下行 挖得更深 嵌套在todo-database中的volumes元素告诉Compose将名为database的卷装载到todo-data服务的容器中的/data/db。 顶级卷元素定义并配置名为卷的数据库Compose文件中的任何服务都可以使用该数据库。 5、Delete adn restart Now, no matter how often you delete and restart the container, your data is persisted and accessible to any container on your system by mounting the database volume. Docker will check for a volume and create one if there is none present. 现在无论您多久删除和重新启动一次容器您的数据都是持久的并且可以通过装载数据库卷对系统上的任何容器进行访问。Docker将检查一个卷如果没有则创建一个卷。 相关文章 【Docker】linux、nginx、容器镜像三者基本概念 【Docker】在Windows下使用Docker Desktop创建nginx容器并访问默认网站 【Docker】在Windows操作系统上安装Docker 【Docker】了解Docker Desktop桌面应用程序TA是如何管理和运行Docker容器1 【Docker】使用VS创建、运行、打包、部署.net core 6.0 webapi Docker学习文档中心https://docs.docker.com/ 总结温故而知新不同阶段重温知识点会有不一样的认识和理解博主将巩固一遍知识点并以实践方式和大家分享若能有所帮助和收获这将是博主最大的创作动力和荣幸。也期待认识更多优秀新老博主。