In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use ncenter command to enter Docker container", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to use the nsenter command to enter the Docker container"!
The nsenter command is a command that runs a specified program in the command space of a specified process. One of the most typical uses is to enter the container's network command space.
Check that there is no nsenter installed.
whereis ncenter or whatis ncenter
Install before installing. There are many such scripts on the Internet.
vi nsenter.sh#!/ bin/bashcurl https://www.kernel.org/pub/linux/utils/util-linux/v2.24/util-linux-2.24.tar.gz | tar -zxf-cd util-linux-2.24./ configure --without-ncursesmake nsentersudo cp nsenter /usr/local/bincd .. && rm -rf util-linux-2.24 Save exit, execute script to install ncenter. If the error, pay attention to read the error message, I installed gcc to solve this problem, and then use the following script to enter the container. vi docker_enter.sh#!/ bin/sh#File name: docker_enter.sh#Version: 1.0.1#Usage: Use nsenter tool to enter Docker container #Usage: . docker_enter Container ID or bash -x docker_enter.sh Container ID#Text: such as the following code if [ -e $(dirname "$0")/nsenter ]; thenNSENTER=$(dirname "$0")/nsenterseSENTER =nsenterfiif [ -z "$1" ]; thenecho "Usage: `basename "$0"` CONTAINER [COMMAND [ARG]...] "echo ""echo "Enters the Docker CONTAINER and executes the specified COMMAND. "echo "If COMMAND is not specified, runs an interactive shell in CONTAINER. "elsePID=$(docker inspect --format "{{.State.Pid}}" "$1")if [ -z "$PID" ]; thenexit 1fishiftOPTS="--target $PID --mount --uts --ipc --net --pid --"if [ -z "$1" ]; then# No command given.# Use su to clear all host environment variables except for TERM,# initialize the environment variables HOME, SHELL, USER, LOGNAME, PATH,# and start a login shell. "$NSENTER" $OPTS su - rootelse# Use env to clear all host environment variables. "$NSENTER" $OPTS env --ignore-environment -- "$@"fifi
Save exit, command line execution. docker_enter container ID or bash -x docker_enter.sh container ID, you can successfully enter the container
At this point, I believe that everyone has a deeper understanding of "how to use the ncenter command to enter the Docker container", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
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.