What other `namespace` oriented linux commands are there?How to find the network namespace of a veth peer ifindex?How to move process from one namespace to other?linux namespace, How to connect internet in network namespace?remove link from Linux namespaceWhat are the ways and risks of using linux namespaces as nonroot user?Internet connectivity using linux network namespaceDid the pivot_root() documentation anticipate the feature of mount namespaces?Linux mount namespace hopping considered harmful?Could the mount namespace API effectively be made redundant? What obstacles would there be?Understanding how mount namespaces work in LinuxWhat happens to the mount namespace of an interrupted process
(Codewars) Linked Lists-Sorted Insert
Sampling from Gaussian mixture models, when are the sampled data independent?
Are all players supposed to be able to see each others' character sheets?
How can a demon take control of a human body during REM sleep?
Was it really inappropriate to write a pull request for the company I interviewed with?
Volume of hyperbola revolved about the y -axis
What is Tony Stark injecting into himself in Iron Man 3?
Why is there an extra space when I type "ls" on the Desktop?
Is this Paypal Github SDK reference really a dangerous site?
Which country has more?
Did Amazon pay $0 in taxes last year?
Why restrict private health insurance?
-1 to the power of a irrational number
Why does this boat have a landing pad? (SpaceX's GO Searcher) Any plans for propulsive capsule landings?
Locked Away- What am I?
Why do phishing e-mails use faked e-mail addresses instead of the real one?
Can I negotiate a patent idea for a raise, under French law?
Can one live in the U.S. and not use a credit card?
What does *dead* mean in *What do you mean, dead?*?
Computation logic of Partway in TikZ
Yet another question on sums of the reciprocals of the primes
Logistic regression BIC: what's the right N?
Too soon for a plot twist?
How should I solve this integral with changing parameters?
What other `namespace` oriented linux commands are there?
How to find the network namespace of a veth peer ifindex?How to move process from one namespace to other?linux namespace, How to connect internet in network namespace?remove link from Linux namespaceWhat are the ways and risks of using linux namespaces as nonroot user?Internet connectivity using linux network namespaceDid the pivot_root() documentation anticipate the feature of mount namespaces?Linux mount namespace hopping considered harmful?Could the mount namespace API effectively be made redundant? What obstacles would there be?Understanding how mount namespaces work in LinuxWhat happens to the mount namespace of an interrupted process
By other I mean to say that I ran into the command: nsenter and have been thinking that there might be other tools/commands geared to working with and debugging namespaces. Are there? Keep in mind I'm not asking how they work, just looking to get a broader set of tools for working with docker/k8s, etc.
What other namespace oriented linux commands are there?
namespace containers
add a comment |
By other I mean to say that I ran into the command: nsenter and have been thinking that there might be other tools/commands geared to working with and debugging namespaces. Are there? Keep in mind I'm not asking how they work, just looking to get a broader set of tools for working with docker/k8s, etc.
What other namespace oriented linux commands are there?
namespace containers
1
cgroups tag why? namespaces and cgroups are two different things.
– sourcejedi
2 days ago
Hmm, I guess I've always considered them highly-related. My mistake.
– lucidquiet
1 hour ago
add a comment |
By other I mean to say that I ran into the command: nsenter and have been thinking that there might be other tools/commands geared to working with and debugging namespaces. Are there? Keep in mind I'm not asking how they work, just looking to get a broader set of tools for working with docker/k8s, etc.
What other namespace oriented linux commands are there?
namespace containers
By other I mean to say that I ran into the command: nsenter and have been thinking that there might be other tools/commands geared to working with and debugging namespaces. Are there? Keep in mind I'm not asking how they work, just looking to get a broader set of tools for working with docker/k8s, etc.
What other namespace oriented linux commands are there?
namespace containers
namespace containers
edited 57 mins ago
sourcejedi
24.9k441107
24.9k441107
asked 2 days ago
lucidquietlucidquiet
694277
694277
1
cgroups tag why? namespaces and cgroups are two different things.
– sourcejedi
2 days ago
Hmm, I guess I've always considered them highly-related. My mistake.
– lucidquiet
1 hour ago
add a comment |
1
cgroups tag why? namespaces and cgroups are two different things.
– sourcejedi
2 days ago
Hmm, I guess I've always considered them highly-related. My mistake.
– lucidquiet
1 hour ago
1
1
cgroups tag why? namespaces and cgroups are two different things.
– sourcejedi
2 days ago
cgroups tag why? namespaces and cgroups are two different things.
– sourcejedi
2 days ago
Hmm, I guess I've always considered them highly-related. My mistake.
– lucidquiet
1 hour ago
Hmm, I guess I've always considered them highly-related. My mistake.
– lucidquiet
1 hour ago
add a comment |
1 Answer
1
active
oldest
votes
[Are there] other tools/commands geared to working with and debugging namespaces ?
nsenter is the most important one. There are some more, but not very many. I think I can usefully attempt to list them all.
/proc/[pid]/ns/*- You already know about this, because you looked atnsenter. There are a couple more specifics in namespaces(7) :- The above files appear as symbolic links. Running
readlink/ls -lwill show the namespace type, and a unique identifier. - You can keep a permanent reference to a namespace by bind-mounting the above files. If you think this sounds a bit weird, I agree with you, but it can be useful in some cases :-).
- The above files appear as symbolic links. Running
lsns - It crawls/procfor you, and lists all the different namespaces that are being used./proc/[pid]/mountinfodescribes the mount namespace. It is documented in proc(5).Take care the first time you look at it, because there are many columns. For example, there are two different "options" columns with potentially differing values for
rw/ro. The difference is that the column for "mount options" can vary between bind-mounts of the same filesystem.findmntis the standard command to list mounted filesystems. It has an option--task TID- so you can use it to parse themountinfofile of any process. (A PID value is also a valid TID)./proc/[pid]/uid_mapand/proc/[pid]/gid_map, for user_namespaces.- The
ipcommand used to control network interfaces:
ip netns provides some commands for network namespaces specifically. I.e. it just uses thenetfile in/proc/[pid]/ns/as described above.ip linkcan show information aboutvethpeers, including a local identifier for the netns the peer is in.ip netns list-idorlsns -t netwill list network namespaces including this local identifier. I'm not exactly sure how you work with these local identifiers, it seems a bit obscure. But I think this QA mentions everything you can do with them: How to find the network namespace of a veth peer ifindex?ipalso lets you move an interface from one netns to another. Although that's not so much about debugging.
"I’m looking at you, single binary go containers"
Adapted from How-to Debug a Running Docker Container from a Separate Container :
There is a problem with using nsenter. If you enter the mount namespace of a container, you can only run commands that were included in the container. But the point of Docker containers is that they only need to include the application itself!
The trick is that you can access the files inside the container, using /proc/[pid]/root/. (Documented in proc(5)).
This is very convenient if you have entered the PID namespace of a container, because you can use /proc/1/root/. At that point, you don't have to search for the right PID :-).
Having entered the PID namespace, it could also be quite convenient if you know the process you want to attach a debugger to will be PID 1 (or perhaps PID 2) inside the container :-). Alternatively, if your application/container is multi-process, you can use your favourite ps command to look at the different processes.
Probablyunsharealso deserves mentioning...
– Danila Kiver
2 hours ago
@DanilaKiver or maybe get the question clarified as extending beyond "working with docker/k8s, etc" :-P. If I can add onlyunsharethen I agree, but I'm not sure. I treated this as an exercise in showing how little more there is to know, at least about the low-level primitives :-).
– sourcejedi
2 hours ago
@DanilaKiver if you want to inspect a container namespace, you enter the namespace and use the usual system calls. That's almost all you can do.
– sourcejedi
2 hours ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f504928%2fwhat-other-namespace-oriented-linux-commands-are-there%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
[Are there] other tools/commands geared to working with and debugging namespaces ?
nsenter is the most important one. There are some more, but not very many. I think I can usefully attempt to list them all.
/proc/[pid]/ns/*- You already know about this, because you looked atnsenter. There are a couple more specifics in namespaces(7) :- The above files appear as symbolic links. Running
readlink/ls -lwill show the namespace type, and a unique identifier. - You can keep a permanent reference to a namespace by bind-mounting the above files. If you think this sounds a bit weird, I agree with you, but it can be useful in some cases :-).
- The above files appear as symbolic links. Running
lsns - It crawls/procfor you, and lists all the different namespaces that are being used./proc/[pid]/mountinfodescribes the mount namespace. It is documented in proc(5).Take care the first time you look at it, because there are many columns. For example, there are two different "options" columns with potentially differing values for
rw/ro. The difference is that the column for "mount options" can vary between bind-mounts of the same filesystem.findmntis the standard command to list mounted filesystems. It has an option--task TID- so you can use it to parse themountinfofile of any process. (A PID value is also a valid TID)./proc/[pid]/uid_mapand/proc/[pid]/gid_map, for user_namespaces.- The
ipcommand used to control network interfaces:
ip netns provides some commands for network namespaces specifically. I.e. it just uses thenetfile in/proc/[pid]/ns/as described above.ip linkcan show information aboutvethpeers, including a local identifier for the netns the peer is in.ip netns list-idorlsns -t netwill list network namespaces including this local identifier. I'm not exactly sure how you work with these local identifiers, it seems a bit obscure. But I think this QA mentions everything you can do with them: How to find the network namespace of a veth peer ifindex?ipalso lets you move an interface from one netns to another. Although that's not so much about debugging.
"I’m looking at you, single binary go containers"
Adapted from How-to Debug a Running Docker Container from a Separate Container :
There is a problem with using nsenter. If you enter the mount namespace of a container, you can only run commands that were included in the container. But the point of Docker containers is that they only need to include the application itself!
The trick is that you can access the files inside the container, using /proc/[pid]/root/. (Documented in proc(5)).
This is very convenient if you have entered the PID namespace of a container, because you can use /proc/1/root/. At that point, you don't have to search for the right PID :-).
Having entered the PID namespace, it could also be quite convenient if you know the process you want to attach a debugger to will be PID 1 (or perhaps PID 2) inside the container :-). Alternatively, if your application/container is multi-process, you can use your favourite ps command to look at the different processes.
Probablyunsharealso deserves mentioning...
– Danila Kiver
2 hours ago
@DanilaKiver or maybe get the question clarified as extending beyond "working with docker/k8s, etc" :-P. If I can add onlyunsharethen I agree, but I'm not sure. I treated this as an exercise in showing how little more there is to know, at least about the low-level primitives :-).
– sourcejedi
2 hours ago
@DanilaKiver if you want to inspect a container namespace, you enter the namespace and use the usual system calls. That's almost all you can do.
– sourcejedi
2 hours ago
add a comment |
[Are there] other tools/commands geared to working with and debugging namespaces ?
nsenter is the most important one. There are some more, but not very many. I think I can usefully attempt to list them all.
/proc/[pid]/ns/*- You already know about this, because you looked atnsenter. There are a couple more specifics in namespaces(7) :- The above files appear as symbolic links. Running
readlink/ls -lwill show the namespace type, and a unique identifier. - You can keep a permanent reference to a namespace by bind-mounting the above files. If you think this sounds a bit weird, I agree with you, but it can be useful in some cases :-).
- The above files appear as symbolic links. Running
lsns - It crawls/procfor you, and lists all the different namespaces that are being used./proc/[pid]/mountinfodescribes the mount namespace. It is documented in proc(5).Take care the first time you look at it, because there are many columns. For example, there are two different "options" columns with potentially differing values for
rw/ro. The difference is that the column for "mount options" can vary between bind-mounts of the same filesystem.findmntis the standard command to list mounted filesystems. It has an option--task TID- so you can use it to parse themountinfofile of any process. (A PID value is also a valid TID)./proc/[pid]/uid_mapand/proc/[pid]/gid_map, for user_namespaces.- The
ipcommand used to control network interfaces:
ip netns provides some commands for network namespaces specifically. I.e. it just uses thenetfile in/proc/[pid]/ns/as described above.ip linkcan show information aboutvethpeers, including a local identifier for the netns the peer is in.ip netns list-idorlsns -t netwill list network namespaces including this local identifier. I'm not exactly sure how you work with these local identifiers, it seems a bit obscure. But I think this QA mentions everything you can do with them: How to find the network namespace of a veth peer ifindex?ipalso lets you move an interface from one netns to another. Although that's not so much about debugging.
"I’m looking at you, single binary go containers"
Adapted from How-to Debug a Running Docker Container from a Separate Container :
There is a problem with using nsenter. If you enter the mount namespace of a container, you can only run commands that were included in the container. But the point of Docker containers is that they only need to include the application itself!
The trick is that you can access the files inside the container, using /proc/[pid]/root/. (Documented in proc(5)).
This is very convenient if you have entered the PID namespace of a container, because you can use /proc/1/root/. At that point, you don't have to search for the right PID :-).
Having entered the PID namespace, it could also be quite convenient if you know the process you want to attach a debugger to will be PID 1 (or perhaps PID 2) inside the container :-). Alternatively, if your application/container is multi-process, you can use your favourite ps command to look at the different processes.
Probablyunsharealso deserves mentioning...
– Danila Kiver
2 hours ago
@DanilaKiver or maybe get the question clarified as extending beyond "working with docker/k8s, etc" :-P. If I can add onlyunsharethen I agree, but I'm not sure. I treated this as an exercise in showing how little more there is to know, at least about the low-level primitives :-).
– sourcejedi
2 hours ago
@DanilaKiver if you want to inspect a container namespace, you enter the namespace and use the usual system calls. That's almost all you can do.
– sourcejedi
2 hours ago
add a comment |
[Are there] other tools/commands geared to working with and debugging namespaces ?
nsenter is the most important one. There are some more, but not very many. I think I can usefully attempt to list them all.
/proc/[pid]/ns/*- You already know about this, because you looked atnsenter. There are a couple more specifics in namespaces(7) :- The above files appear as symbolic links. Running
readlink/ls -lwill show the namespace type, and a unique identifier. - You can keep a permanent reference to a namespace by bind-mounting the above files. If you think this sounds a bit weird, I agree with you, but it can be useful in some cases :-).
- The above files appear as symbolic links. Running
lsns - It crawls/procfor you, and lists all the different namespaces that are being used./proc/[pid]/mountinfodescribes the mount namespace. It is documented in proc(5).Take care the first time you look at it, because there are many columns. For example, there are two different "options" columns with potentially differing values for
rw/ro. The difference is that the column for "mount options" can vary between bind-mounts of the same filesystem.findmntis the standard command to list mounted filesystems. It has an option--task TID- so you can use it to parse themountinfofile of any process. (A PID value is also a valid TID)./proc/[pid]/uid_mapand/proc/[pid]/gid_map, for user_namespaces.- The
ipcommand used to control network interfaces:
ip netns provides some commands for network namespaces specifically. I.e. it just uses thenetfile in/proc/[pid]/ns/as described above.ip linkcan show information aboutvethpeers, including a local identifier for the netns the peer is in.ip netns list-idorlsns -t netwill list network namespaces including this local identifier. I'm not exactly sure how you work with these local identifiers, it seems a bit obscure. But I think this QA mentions everything you can do with them: How to find the network namespace of a veth peer ifindex?ipalso lets you move an interface from one netns to another. Although that's not so much about debugging.
"I’m looking at you, single binary go containers"
Adapted from How-to Debug a Running Docker Container from a Separate Container :
There is a problem with using nsenter. If you enter the mount namespace of a container, you can only run commands that were included in the container. But the point of Docker containers is that they only need to include the application itself!
The trick is that you can access the files inside the container, using /proc/[pid]/root/. (Documented in proc(5)).
This is very convenient if you have entered the PID namespace of a container, because you can use /proc/1/root/. At that point, you don't have to search for the right PID :-).
Having entered the PID namespace, it could also be quite convenient if you know the process you want to attach a debugger to will be PID 1 (or perhaps PID 2) inside the container :-). Alternatively, if your application/container is multi-process, you can use your favourite ps command to look at the different processes.
[Are there] other tools/commands geared to working with and debugging namespaces ?
nsenter is the most important one. There are some more, but not very many. I think I can usefully attempt to list them all.
/proc/[pid]/ns/*- You already know about this, because you looked atnsenter. There are a couple more specifics in namespaces(7) :- The above files appear as symbolic links. Running
readlink/ls -lwill show the namespace type, and a unique identifier. - You can keep a permanent reference to a namespace by bind-mounting the above files. If you think this sounds a bit weird, I agree with you, but it can be useful in some cases :-).
- The above files appear as symbolic links. Running
lsns - It crawls/procfor you, and lists all the different namespaces that are being used./proc/[pid]/mountinfodescribes the mount namespace. It is documented in proc(5).Take care the first time you look at it, because there are many columns. For example, there are two different "options" columns with potentially differing values for
rw/ro. The difference is that the column for "mount options" can vary between bind-mounts of the same filesystem.findmntis the standard command to list mounted filesystems. It has an option--task TID- so you can use it to parse themountinfofile of any process. (A PID value is also a valid TID)./proc/[pid]/uid_mapand/proc/[pid]/gid_map, for user_namespaces.- The
ipcommand used to control network interfaces:
ip netns provides some commands for network namespaces specifically. I.e. it just uses thenetfile in/proc/[pid]/ns/as described above.ip linkcan show information aboutvethpeers, including a local identifier for the netns the peer is in.ip netns list-idorlsns -t netwill list network namespaces including this local identifier. I'm not exactly sure how you work with these local identifiers, it seems a bit obscure. But I think this QA mentions everything you can do with them: How to find the network namespace of a veth peer ifindex?ipalso lets you move an interface from one netns to another. Although that's not so much about debugging.
"I’m looking at you, single binary go containers"
Adapted from How-to Debug a Running Docker Container from a Separate Container :
There is a problem with using nsenter. If you enter the mount namespace of a container, you can only run commands that were included in the container. But the point of Docker containers is that they only need to include the application itself!
The trick is that you can access the files inside the container, using /proc/[pid]/root/. (Documented in proc(5)).
This is very convenient if you have entered the PID namespace of a container, because you can use /proc/1/root/. At that point, you don't have to search for the right PID :-).
Having entered the PID namespace, it could also be quite convenient if you know the process you want to attach a debugger to will be PID 1 (or perhaps PID 2) inside the container :-). Alternatively, if your application/container is multi-process, you can use your favourite ps command to look at the different processes.
edited 1 min ago
answered 2 days ago
sourcejedisourcejedi
24.9k441107
24.9k441107
Probablyunsharealso deserves mentioning...
– Danila Kiver
2 hours ago
@DanilaKiver or maybe get the question clarified as extending beyond "working with docker/k8s, etc" :-P. If I can add onlyunsharethen I agree, but I'm not sure. I treated this as an exercise in showing how little more there is to know, at least about the low-level primitives :-).
– sourcejedi
2 hours ago
@DanilaKiver if you want to inspect a container namespace, you enter the namespace and use the usual system calls. That's almost all you can do.
– sourcejedi
2 hours ago
add a comment |
Probablyunsharealso deserves mentioning...
– Danila Kiver
2 hours ago
@DanilaKiver or maybe get the question clarified as extending beyond "working with docker/k8s, etc" :-P. If I can add onlyunsharethen I agree, but I'm not sure. I treated this as an exercise in showing how little more there is to know, at least about the low-level primitives :-).
– sourcejedi
2 hours ago
@DanilaKiver if you want to inspect a container namespace, you enter the namespace and use the usual system calls. That's almost all you can do.
– sourcejedi
2 hours ago
Probably
unshare also deserves mentioning...– Danila Kiver
2 hours ago
Probably
unshare also deserves mentioning...– Danila Kiver
2 hours ago
@DanilaKiver or maybe get the question clarified as extending beyond "working with docker/k8s, etc" :-P. If I can add only
unshare then I agree, but I'm not sure. I treated this as an exercise in showing how little more there is to know, at least about the low-level primitives :-).– sourcejedi
2 hours ago
@DanilaKiver or maybe get the question clarified as extending beyond "working with docker/k8s, etc" :-P. If I can add only
unshare then I agree, but I'm not sure. I treated this as an exercise in showing how little more there is to know, at least about the low-level primitives :-).– sourcejedi
2 hours ago
@DanilaKiver if you want to inspect a container namespace, you enter the namespace and use the usual system calls. That's almost all you can do.
– sourcejedi
2 hours ago
@DanilaKiver if you want to inspect a container namespace, you enter the namespace and use the usual system calls. That's almost all you can do.
– sourcejedi
2 hours ago
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f504928%2fwhat-other-namespace-oriented-linux-commands-are-there%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
cgroups tag why? namespaces and cgroups are two different things.
– sourcejedi
2 days ago
Hmm, I guess I've always considered them highly-related. My mistake.
– lucidquiet
1 hour ago