• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How To Mount Host System's Volume To The Docker Container On Rocky Linux 8.6

  • 00:01 docker pull caddy
  • 00:27 cat /etc/os-release
  • 00:40 systemctl status docker.service
  • 01:44 echo "welcome to linuxhelp" > index.html
  • 02:14 mkdir caddy_data
  • 02:29 docker run -d -p 80:80 \
{{postValue.id}}

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 snap 1

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.

Tags:
michael
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is the mount in Docker?

A

When you use a bind mount, a file or directory on the host machine is mounted into a container

Q

How does the docker bind mount work?

A

Bind mounts will mount a file or directory onto your container from your host machine, which you can then reference via its absolute path.

Q

What if mounting Directories are not present in the Host System?

A

If mounting Directories are not present in the Host System, they will be created on demand.

Q

What is the docker secret?

A

In terms of Docker Swarm services, a secret is a blob of data, such as a password, SSH private key, SSL certificate, or another piece of data that should not be transmitted over a network or stored unencrypted in a Dockerfile or in your application's source code.

Q

How to Mount a Host System Directory to the Docker Container?

A

To Mount, a Host System Directory to the Docker Container use Command "docker run -v :"

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Jayce ?
What are the types of table used in IPtables

What are the various types of table used in IPtables and how to use that for my server security?

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.