@@ -75,23 +75,52 @@ docker volume create --driver local --opt type=nfs --opt o=addr=<ip-address-of-n
7575```
7676
7777Output:
78- ![ shows the name of the docker volume] ( /images/blog/nfs-as-docker-volume/create-volume.png )
78+
79+ ``` text
80+ $ docker volume create --driver local \
81+ --opt type=nfs --opt o=addr=192.168.1.7,rw \
82+ --opt device=:/srv/nfs nfs-volume
83+ nfs volume
84+ ```
7985
8086> To verify that the volume was created successfully, I used this command.
8187
8288``` bash
8389docker volume ls
8490```
8591
86- ** It would show like this**
87- ![ shows the list of available docker volumes] ( /images/blog/nfs-as-docker-volume/docker-vol-ls.png )
92+ ** Output:**
93+
94+ ``` text
95+ $ docker volume ls
96+ DRIVER VOLUME NAME
97+ local nfs-volume
98+ ```
8899
89100## Mounting NFS in a Container: A Moment of Truth
90101
91102Next, I mounted the NFS volume in a container using the docker run command. I specified the NFS volume and the mount point in the --mount section.
92103
104+ > To mount the NFS volume in a container, you can use the following command:
105+
106+ ``` bash
107+ docker run --name nfs_mounted_node_container \
108+ --mount source=nfs-volume,target=/opt node
109+ ```
110+
93111** Output:**
94- ![ shows the container id] ( /images/blog/nfs-as-docker-volume/docker-run.png )
112+
113+ ``` text
114+ $ docker run --name nfs_mounted_node_container \
115+ --mount source=nfs-volume,target=/opt \
116+ alpine
117+ Unable to find image 'alphine:latest' locally
118+ latest: Pulling from library/alphine
119+ 5e6ec7f28fbf: Pull complete
120+ Digest: sha256:185518070891758909c9f839cf4ca393ee977ac378609f700f60a6718c2b6d6a
121+ Status: Downloaded newer image for alphine:latest
122+ 1d7e2e2b8e2e0d1
123+ ```
95124
96125> To verify, we can use the following command with docker exec:
97126
@@ -104,7 +133,13 @@ mount | grep /opt
104133```
105134
106135It will display something similar to this
107- ![ shows that the mounted directory is of nfs type] ( /images/blog/nfs-as-docker-volume/result.png )
136+
137+ ``` text
138+ $ docker exec -it nfs_mounted_node_container sh
139+ # mount | grep /opt
140+ :/ on /opt type nfs4
141+ (rw,relatime,vers=4.0,risze=104348,wsize=1932432)
142+ ```
108143
109144## Docker Compose and NFS: Expanding Horizons
110145
0 commit comments