[Docker] Create a Volume

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[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.

 

以上是关于[Docker] Create a Volume的主要内容,如果未能解决你的问题,请参考以下文章

如何更改“docker create volume”命令的默认位置?

深入理解docker volume

docker挂载volume的用户权限问题

docker启动报错解决及分析(Cannot create container for service *******: cannot mount volume over existing file,

docker volume创建时能不能指定size

操作docker容器