In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge about "how to soft connect to the host directory in docker container". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
How do docker containers softlink to host directories? When the docker container is started, if you want to mount a directory on the host, you can specify it with the-v parameter.
If you want to start a centos container, mount the host's/test directory to the container's/soft directory by specifying:
# docker run -it -v /test:/soft centos /bin/bash
This way, after the container is started, the/soft directory will be automatically created in the container. In this way, we can make it clear that in the-v parameter, the directory before the colon ":" is the host directory, and the directory after it is the directory inside the container.
Here's how to verify it:
1. Container directories cannot be relative paths.
[root@localhost ~]# docker run -it -v /test:soft centos /bin/bashinvalid value "/test:soft" for flag -v: soft is not an absolute pathSee 'docker run --help'.
Direct error, prompt soft is not an absolute path, the so-called absolute path, must be the following slash "/" beginning.
If the host directory does not exist, it will be automatically generated.
If the/test directory exists on the host, delete it first
[root@localhost ~]# rm -rf /test[root@localhost ~]# ls /bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
start the container
[root@localhost ~]# docker run -it -v /test:/soft centos /bin/bash[root@a487a3ca7997 /]# lsbin dev etc home lib lib64 lost+found media mnt opt proc root run sbin soft srv sys tmp usr var
Check the host and find a new/test directory
[root@localhost ~]# ls /bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys test tmp usr var
Third, mount the host already exists in the directory, in the container to operate on it, reported "Permission denied" can be solved in two ways:
1> Close selinux.
Temporary shutdown: # setenforce 0
Permanent shutdown: Modify the/etc/sysconfig/selinux file to set the value of SELINUX to disabled.
2> Start container in privileged mode
Specify the-privileged parameter, such as:
# docker run -it --privileged=true -v /test:/soft centos /bin/bash
"docker container how to soft link to the host directory" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.