In this lab, I will show Data-packed Volume Container.
Data-packed volume container can put the date in a volume container and then share this date to other container.
1. Let me edit the index.html and a dockfile first.
peter@peter-KVM:~$ cat /home/peter/htdocs/index.html This content is from data packer volume container peter@peter-KVM:~$ peter@peter-KVM:~$ cat /home/peter/Dockerfiles/datapacked/Dockerfile FROM busybox:latest ADD htdocs /usr/local/apache2/htdocs VOLUME /usr/local/apache2/htdocs peter@peter-KVM:~$
2. Using the Dockerfile to build a image called datapacked
peter@peter-KVM:~$ docker build -t datapacked . -f /home/peter/Dockerfiles/datapacked/Dockerfile Sending build context to Docker daemon 1.378MB Step 1/3 : FROM busybox:latest ---> 64f5d945efcc Step 2/3 : ADD htdocs /usr/local/apache2/htdocs ---> 72bc436de880 Step 3/3 : VOLUME /usr/local/apache2/htdocs ---> Running in cf714daca96d Removing intermediate container cf714daca96d ---> d59c97deb637 Successfully built d59c97deb637 Successfully tagged datapacked:latest peter@peter-KVM:~$
3. Using this image (datapacked) to create a data-packed volume container called vc_data, but do not run it.
peter@peter-KVM:~$ docker create --name vc_data datapacked 0400afc715b86c0b8947f3a46958da6c34c47f42818b54adf2f977c195f8a625 peter@peter-KVM:~$
4. Runing another container(httpd) and using the data-packed volume container.
peter@peter-KVM:~$ docker run -d -p 80:80 --volumes-from vc_data httpd 4ad16023a20e4ff4939f48cadd9f5f4c540e6e987b79c2eb3e596cb3a7451fc8 peter@peter-KVM:~$
5. Verify the index.html in the httpd container.
peter@peter-KVM:~$ curl 127.0.0.1:80 This content is from data packer volume container peter@peter-KVM:~$
最初發表 / 最後更新: 2019.06.08 / 2019.06.08
0 comments:
張貼留言