Docker data volume container creation and usage analysis

Docker data volume container creation and usage analysis

A data volume container is a container specifically used to mount data volumes. This container is mainly referenced and used by other containers. The so-called data volume container is actually an ordinary container, as shown below:

Create a data volume container

Create a data volume container using the following method:

docker run -itd -v /usr/share/nginx/html/ --name mydata ubuntu

The command execution effect is as follows:

Reference Container

Use the following command to reference the data volume container:

docker run -itd --volumes-from mydata -p 80:80 --name nginx1 nginx
docker run -itd --volumes-from mydata -p 81:80 --name nginx2 nginx

At this point, nginx1 and nginx2 both mount the same data volume to the /usr/share/nginx/html/ directory. If any of the three containers is modified,

The files in this directory can be seen in the other two.

At this point, use the docker inspect command to view the details of the container and find that the descriptions of the data volumes of the three containers are consistent, as shown below:

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Steps to set up and mount shared folders on Windows host and Docker container
  • Docker deploys nginx and mounts folders and file operations
  • Docker mounts local directories and data volume container operations

<<:  JavaScript to achieve uniform animation effect

>>:  How to dynamically modify the replication filter in mysql

Recommend

A case study on MySQL optimization

1. Background A sql-killer process is set up on e...

MySQL 8.0.12 decompression version installation tutorial

This article shares the installation tutorial of ...

Vue implements simple calculator function

This article example shares the specific code of ...

Solution to 1290 error when importing file data in mysql

Error scenario Use the mysql command in cmd to ad...

Detailed tutorial on installing Docker on CentOS 8

1. Previous versions yum remove docker docker-cli...

Six-step example code for JDBC connection (connecting to MySQL)

Six steps of JDBC: 1. Register the driver 2. Get ...

MySQL 5.7.15 version installation and configuration method graphic tutorial

This article shares with you a detailed tutorial ...

Use of MySQL stress testing tool Mysqlslap

1. MySQL's own stress testing tool Mysqlslap ...

Detailed explanation of js event delegation

1. Each function is an object and occupies memory...

CSS code to distinguish ie8/ie9/ie10/ie11 chrome firefox

Website compatibility debugging is really annoyin...

How to implement rounded corners with CSS3 using JS

I found an example when I was looking for a way t...