.\" -*- coding: UTF-8 -*- .if \n(.g .ds T< \\FC .if \n(.g .ds T> \\F[\n[.fam]] .de URL \\$2 \(la\\$1\(ra\\$3 .. .if \n(.g .mso www.tmac .TH lxc-unshare 1 2024-09-16 "" "" .SH NAME lxc-unshare \- Run a task in a new set of namespaces. .SH SYNOPSIS 'nh .fi .ad l \fBlxc-unshare\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu {-s, --namespaces \fInamespaces\fR} [-u, --user \fIuser\fR] [-H, --hostname \fIhostname\fR] [-i, --ifname \fIifname\fR] [-d, --daemon] [-M, --remount] {command} 'in \n(.iu-\nxu .ad b 'hy .SH DESCRIPTION \fBlxc-unshare\fR can be used to run a task in a cloned set of namespaces. This command is mainly provided for testing purposes. Despite its name, it always uses clone rather than unshare to create the new task with fresh namespaces. Apart from testing kernel regressions this should make no difference. .SH OPTIONS .TP \*(T<\fB\-s, \-\-namespaces \fR\*(T>\fInamespaces\fR Specify the namespaces to attach to, as a pipe-separated list, e.g. \fINETWORK|IPC\fR. Allowed values are \fIMOUNT\fR, \fIPID\fR, \fIUTSNAME\fR, \fIIPC\fR, \fIUSER \fRand \fINETWORK\fR. This allows one to change the context of the process to e.g. the network namespace of the container while retaining the other namespaces as those of the host. (The pipe symbol needs to be escaped, e.g. \fIMOUNT\e|PID\fR or quoted, e.g. \fI"MOUNT|PID"\fR.) .TP \*(T<\fB\-u, \-\-user \fR\*(T>\fIuser\fR Specify a userid which the new task should become. .TP \*(T<\fB\-H, \-\-hostname \fR\*(T>\fIhostname\fR Set the hostname in the new container. Only allowed if the UTSNAME namespace is set. .TP \*(T<\fB\-i, \-\-ifname \fR\*(T>\fIinterfacename\fR Move the named interface into the container. Only allowed if the NETWORK namespace is set. You may specify this argument multiple times to move multiple interfaces into container. .TP \*(T<\fB\-d, \-\-daemon\fR\*(T> Daemonize (do not wait for the container to exit before exiting) .TP \*(T<\fB\-M, \-\-remount\fR\*(T> Mount default filesystems (/proc /dev/shm and /dev/mqueue) in the container. Only allowed if MOUNT namespace is set. .SH EXAMPLES To spawn a new shell with its own UTS (hostname) namespace, .nf \*(T< lxc\-unshare \-s UTSNAME /bin/bash \*(T> .fi If the hostname is changed in that shell, the change will not be reflected on the host. .PP To spawn a shell in a new network, pid, and mount namespace, .nf \*(T< lxc\-unshare \-s "NETWORK|PID|MOUNT" /bin/bash \*(T> .fi The resulting shell will have pid 1 and will see no network interfaces. After re-mounting /proc in that shell, .nf \*(T< mount \-t proc proc /proc \*(T> .fi ps output will show there are no other processes in the namespace. .PP To spawn a shell in a new network, pid, mount, and hostname namespace. .nf \*(T< lxc\-unshare \-s "NETWORK|PID|MOUNT|UTSNAME" \-M \-H myhostname \-i veth1 /bin/bash \*(T> .fi The resulting shell will have pid 1 and will see two network interfaces (lo and veth1). The hostname will be "myhostname" and /proc will have been remounted. ps output will show there are no other processes in the namespace. .SH "SEE ALSO" \fBlxc\fR(7), \fBlxc-create\fR(1), \fBlxc-copy\fR(1), \fBlxc-destroy\fR(1), \fBlxc-start\fR(1), \fBlxc-stop\fR(1), \fBlxc-execute\fR(1), \fBlxc-console\fR(1), \fBlxc-monitor\fR(1), \fBlxc-wait\fR(1), \fBlxc-cgroup\fR(1), \fBlxc-ls\fR(1), \fBlxc-info\fR(1), \fBlxc-freeze\fR(1), \fBlxc-unfreeze\fR(1), \fBlxc-attach\fR(1), \fBlxc.conf\fR(5)