How To Mount Host System's Volume To The Docker Container On Rocky Linux 8.6
To Mount Host System's Volume to the Docker Container on Rocky Linux 8.6
Introduction:
Docker is a platform for fast 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 ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="8.6 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.6"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.6 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky Linux"
ROCKY_SUPPORT_PRODUCT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8"
Step 2: Check the status of Docker by using the below command
[root@linuxhelp ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2022-07-25 15:21:06 EDT; 2 days ago
Docs: https://docs.docker.com
Main PID: 64735 (dockerd)
Tasks: 10
Memory: 85.4M
CGroup: /system.slice/docker.service
└─64735 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Jul 25 15:21:06 linuxhelp dockerd[64735]: time="2022-07-25T15:21:06.934053163-04:00" level=info msg="Daemon >
Jul 25 15:21:06 linuxhelp systemd[1]: Started Docker Application Container Engine.
Jul 25 15:21:06 linuxhelp dockerd[64735]: time="2022-07-25T15:21:06.958896760-04:00" level=info msg="API lis>
Jul 26 15:41:34 linuxhelp dockerd[64735]: time="2022-07-26T15:41:34.795482381-04:00" level=info msg="ignorin>
Jul 26 15:42:05 linuxhelp dockerd[64735]: time="2022-07-26T15:42:05.720914757-04:00" level=info msg="ignorin>
Jul 26 15:43:28 linuxhelp dockerd[64735]: time="2022-07-26T15:43:28.376281803-04:00" level=info msg="Layer s>
Jul 26 15:46:18 linuxhelp dockerd[64735]: time="2022-07-26T15:46:18.677504815-04:00" level=error msg="Not co>
Jul 26 15:46:18 linuxhelp dockerd[64735]: time="2022-07-26T15:46:18.677944743-04:00" level=info msg="Ignorin>
Jul 26 15:50:09 linuxhelp dockerd[64735]: time="2022-07-26T15:50:09.702009530-04:00" level=info msg="ignorin>
Jul 26 15:55:10 linuxhelp dockerd[64735]: time="2022-07-26T15:55:10.2
Step 3: Pull the caddy Web Server Container from the Docker Hub by using the below command
[root@linuxhelp ~]# docker pull caddy
Using default tag: latest
latest: Pulling from library/caddy
530afca65e2e: Pull complete
4ba0a25d6623: Pull complete
7a501877fabb: Pull complete
d2c62335257e: Pull complete
4e4608ab095f: Pull complete
Digest: sha256:f51603577fef8abe01dfda4b5ef85b3acf2844a6b3d0db873f5119f57db5de57
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 .html 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
[root@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
e20cf1085a2182dedc8a88f9171c634ebde81685381d2c7833ab1c3fc111b41f
Step 9: Ping the http://localhost as shown in the below image
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to Mount Host System's Volume to the Docker Container on Rocky Linux 8.6. Your feedback is much welcome.
Comments ( 0 )
No comments available