首页 > 代码库 > [Docker] Create a Volume

[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