How to Mount Host System's Volume to the Docker Container on Ubuntu 21.04
To Mount Host System Volume to the Docker Container on Ubuntu 21.04
Introduction:
Docker is a platform for quickly building, testing, and deploying applications. In Docker, the software is packaged into standardized units called containers. Containers contain the libraries, tools, code, and runtime that the software needs to run.
Installation Procedure:
Step 1: Check the OS version by using the below command
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.04
Release: 21.04
Codename: hirsute
Step 2: View the Docker version by using the below command
root@linuxhelp:~# docker -v
Docker version 20.10.12, build e91ed57
Step 3: Pull the caddy Web Server Container from the Docker Hub using the below command
root@linuxhelp:~# docker pull caddy
Using default tag: latest
latest: Pulling from library/caddy
97518928ae5f: Pull complete
23ccae726125: Pull complete
3de6a61c89ac: Pull complete
39ed957bdc00: Pull complete
0ae44c2d42dd: Pull complete
Digest: sha256:d72fd3bfc16214ee1fc1733ae88bcacd1bc2f5c97cf050535f97c55cbcbd5876
Status: Downloaded newer image for caddy:latest
docker.io/library/caddy:latest
Step 4: Create a Directory as caddy by using the below command
root@linuxhelp:~# mkdir caddy
Step 5: Change to the caddy directory by using the below command
root@linuxhelp:~# cd caddy/
Step 6: Create a sample file for content in Web Server by using the below command
root@linuxhelp:~/caddy# echo "Welcome to Linuxhelp" > index.html
Step 7: Create a Data directory for Mounting to the Container by using the below command
roo@linuxhelp:~/caddy# mkdir caddy_data
Step 8: Run the Caddy Container in port 80 with Mounting the Create Directories from Host System by using the below command
root@linuxhelp:~/caddy# docker run -d -p 80:80 \
> -v $PWD/index.html:/usr/share/caddy/index.html \
> -v $PWD/caddy_data:/data \
> caddy
b42fb8ca9931e1308aa57e02cb232834e041b8c20241e552fafab15ea9a73630
Step 9: Ping the http://localhost
By this, to Mount Host System Volume to the Docker Container on Ubuntu 21.04 has been completed.
Comments ( 0 )
No comments available