• 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 Ubuntu 21.04

  • 00:34 lsb_release -a
  • 00:44 docker -v
  • 00:54 docker pull caddy
  • 01:24 mkdir caddy
  • 01:30 cd caddy/
  • 01:39 echo "Welcome to Linuxhelp" > index.html
  • 02:11 mkdir caddy_data
  • 02:31 "# docker run -d -p 80:80 \ > -v $PWD/index.html:/usr/share/caddy/index.html \ > -v $PWD/caddy_data:/data \ > caddy "
{{postValue.id}}

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

Snap 1

By this, to Mount Host System Volume to the Docker Container on Ubuntu 21.04 has been completed.

Tags:
connor
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

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 :"

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 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.

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 Isaiah ?
What is the use of SUID & SGID commands

How to set the special permissions to the files and folders using SUID and SGID commands...

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.