[Docker] Create a Volume

We can create volumn to keep the data, even we stop the container and restart again, the data won‘t get lost.

To create a link between the folder /my-files on your host machine and the htdocs folder in the container. This also runs the container in the background.

docker run -d -p 80:80 -v /my-files:/usr/local/apache2/htdocs web-server:1.1

After runnning the container, Let’s see what this looks like from inside the container.

Attache a shell to the container:

docker container exec -it elegant_noether /bin/bash

cd to folder:

cd /usr/local/apache2/htdocs

Now we can use ‘ls -la‘ to see what is inside the folder.

时间: 2025-02-01 17:42:18

[Docker] Create a Volume的相关文章

(转)Docker volume plugin - enabled create local volume on docker host

原文地址:https://hub.docker.com/r/cwspear/docker-local-persist-volume-plugin/ Short Description Create named local volumes that persist in the location(s) you want. Full Description Local Persist Volume Plugin for Docker   Create named local volumes that

有容云——窥探Docker中的Volume Plugin内幕

编者注: 本文根据有容云技术实施团队原创分享内容整理.对Docker技术感兴趣.或对本文中细节需继续探讨的朋友,欢迎加入我们参与讨论! 特别鸣谢中生代技术群分享支持. 注:本期分享由张朝潞原创,有容云整理发布,转载请注明出处 作者介绍: 张朝潞,有容云(Yourun Cloud)平台存储架构师.曾工作于UIT,华三,腾讯,专注分布式存储的研究和开发,对云计算存储解决方案方面有很深的技术造诣和行业理解. 本次交流将与大家分享Docker Volume plugin相关的内容.今日主题是窥探Dock

[Docker] Hooking a Volume to Node.js Source Code

Normally when you create a Volume, it will store in Docket Host, you can also tell the folder which you want docket to store the volume. docker run -p 8080:3000 -v /var/www node # run with a node image You can check the volume information by: docker

解决 Windows Docker 安装 Gitlab Volume 权限问题

本文首发于我的个人博客,解决 Windows Docker 安装 Gitlab Volume 权限问题 ,欢迎访问! 记录一下 Windows10 下 Docker 安装 Gitlab 的步骤. Caution: We do not officially support running on Docker for Windows. There are known issues with volume permissions, and potentially other unknown issue

OpenFiler 2.99.1 can't create physical volume(不能创建物理卷)

在VMware Workstation上做Oracle RAC实验,使用OpenFileresa 2.99.1(openfileresa-2.99.1-x86_64-disc1.iso)作为存储,但是到创建物理卷的时候,点击"create"没有任何反应,至此卡壳,无法继续. 经过Google发现一个比较奇怪的问题,就是创建物理卷时,起始和结束柱面要分别增大和缩减,也就是相当于缩减了实际空间的大小,然后创建成功. 如下,我实际柱面分别是1213-7833,这样是无法create成功的,后

docker create 使用

docker create 创建的镜像不会被启动 docker create centos:7 原文地址:https://www.cnblogs.com/S--S/p/11715710.html

[Docker] Create Docker Volumes for Persistent Storage

Docker containers are stateless by default. In order to persist filesystem changes, you must use docker volumes. In this lesson, we will go over how to copy files over to Docker containers, how to create volumes and copy data to them, and also how to

你必须知道的Docker数据卷(Volume)

本篇已加入<.NET Core on K8S学习实践系列文章索引>,可以点击查看更多容器化技术相关系列文章. 一.将Docker数据挂载到容器 在Docker中,要想实现数据的持久化(所谓Docker的数据持久化即数据不随着Container的结束而结束),需要将数据从宿主机挂载到容器中.目前Docker提供了三种不同的方式将数据从宿主机挂载到容器中: (1)volumes:Docker管理宿主机文件系统的一部分,默认位于 /var/lib/docker/volumes 目录中:(最常用的方式

Docker的数据管理(volume/bind mount/tmpfs)

Docker提供了三种不同的方式用于将宿主的数据挂载到容器中:volumes,bind mounts,tmpfs volumes.当你不知道该选择哪种方式时,记住,volumes总是正确的选择. volumes是Docker数据持久化机制.bind mounts依赖主机目录结构,volumes完全由Docker管理.Volumes有以下优点: Volumes更容易备份和移植. 可以通过Docker CLI或API进行管理 Volumes可以无区别的工作中Windows和Linux下. 多个容器共