Questions tagged [nsenter]

nsenter is a linux command allowing to run a program with namespaces of other processes.

nsenter is a linux command allowing to run a program with namespaces of other processes.

http://man7.org/linux/man-pages/man1/nsenter.1.html

20 questions
18
votes
4 answers

CoreOS - get docker container name by PID?

I have a list of PID's and I need to get their docker container name. Going the other direction is easy ... get PID of docker container by image name: $ docker inspect --format '{{.State.Pid}}' {SOME DOCKER NAME} Any idea how to get the name by…
Nimrod007
  • 9,825
  • 8
  • 48
  • 71
12
votes
2 answers

Docker exec versus nsenter: Any gotchas?

I've been using nsenter for the last few months to get a shell running on a container for debugging purposes. I have heard about and used docker exec which was introduced in version 1.3. Docker exec seems to be the new best practice for the purpose…
L0j1k
  • 12,255
  • 7
  • 53
  • 65
4
votes
3 answers

How to edit a file dynamically in a running docker container

Background I had build a npm server(sinopia) docker image(https://github.com/feuyeux/docker-atue/blob/master/docker-images/feuyeux_sinopia.md), and in the CMD line, it will run the start.sh every time when the container is generated. CMD…
feuyeux
  • 1,158
  • 1
  • 9
  • 26
3
votes
1 answer

How to connect host machine from container using nsenter utility

There is a utility called nsenter in ubuntu. nsenter is a small tool allowing to enter into namespaces. It will enter into your docker container. I want to control the host machine from the docker container. How do I connect the host machine from…
Ashok Kumar
  • 105
  • 2
  • 8
3
votes
1 answer

Python Script to run commands in a Docker container

I am currently working on automating commands for a Docker container with a Python script on the host machine. This Python script for now, builds and runs a docker-compose file, with the commands for the containers written into the docker-compose…
Chris Maze
  • 41
  • 1
  • 3
3
votes
1 answer

Difference between docker privileged mode and kubernetes privilege container

What is the difference in privilege granted to a container in the following 2 scenarios sudo docker run -d --privileged --pid=host alpine:3.8 tail -f /dev/null Using kubernetes apiVersion: v1 kind: Pod metadata: name: nsenter-alpine spec: …
himadri
  • 73
  • 1
  • 7
3
votes
1 answer

Does docker internally uses system calls like chroot, unshare, nsenter, etc or a wrapper around lxc

I was going through an article to build containers from scratch without using docker just by making use of linux system calls like chroot, unshare, nsenter, etc. Does docker internally a wrapper around these system calls, it seems like docker exec…
mchawre
  • 10,744
  • 4
  • 35
  • 57
2
votes
1 answer

What is "/usr/bin/nsenter -m/proc/1/ns/mnt" in Kubernetes Daemonset?

I have read some tutorials of how to mount a volume in container and run the script on host/node directly. These are the examples given. DeamonSet pod spec hostPID: true nodeSelector: cloud.google.com/gke-local-ssd: "true" …
Steve
  • 175
  • 1
  • 3
  • 14
2
votes
2 answers

Environment variable with spaces in a string - How to use them from /proc/pid/environ

I set a variable with spaces in a string to a new bash: VAR='my variable with spaces' /bin/bash And now if I want to start a new bash with the same environment, I would do something like: ENV=$(cat /proc/self/environ | xargs -0 | grep =) env -i -…
Pierre Ozoux
  • 780
  • 7
  • 25
1
vote
1 answer

Reuse namespaces of process started by bubblewrap

Starting a shell with this: bwrap --unshare-pid --unshare-user --dev-bind / / bash In another shell on the host we can see this with lsns: 4026532550 user 2 1799976 user bwrap --unshare-pid --unshare-user --dev-bind / / bash 4026532552 mnt …
Jallan
  • 11
  • 1
1
vote
1 answer

pip install nsenter times out in alpine docker container

I am using alpine:3.7 and i try to install python nsenter package: FROM alpine:3.7 MAINTAINER blah-blah RUN echo "http://dl-2.alpinelinux.org/alpine/v3.7/main" >> /etc/apk/repositories && \ echo…
belabrinel
  • 851
  • 8
  • 15
1
vote
1 answer

Unable to enter Docker container on remote Linux box with procedure that works fine on local box?

I have nsenter set up on my local and remote Linux boxes. The remote box is a hosted virtual machine. The local box is a computer in my office. Both are running Ubuntu 12.0.4 LTS server version and both of them have the kernel patch to support…
Robert Oschler
  • 14,153
  • 18
  • 94
  • 227
0
votes
1 answer

Cannot get into a container namespace with bin/bash

In one terminal I have a running container docker container run --rm -it bash In another terminal I want to run bin/bash in the same namespace as the running container above. For that to happen I followed these steps: Grab the PID of the running…
Vahid
  • 1,625
  • 1
  • 18
  • 33
0
votes
0 answers

Run a process without actually execing into a container using nsenter

Details I wanted to run a process on a container without actually execing into it. This is because the container might not have all the packages installed to run the commands. Like if I want to run a stress command then I might not found stress in…
UDIT GAURAV
  • 53
  • 2
  • 5
0
votes
1 answer

Using nsenter to access docker network that has no running containers attached

Everything I read uses the PID of the container that uses that network. Unfortunately the container dies because of a what I think is a network issue. I want to nsenter into the network namespace and run commands rather than run a different…
user2615862
  • 149
  • 1
  • 10
1
2