Skip to content

Instantly share code, notes, and snippets.

[root@localhost rootfs]# nsinit exec /bin/bash
2014/06/26 21:50:00 EXEC USERNS
2014/06/26 21:50:00 &{MountConfig:0xc21001e3c0 Hostname:koye User:root WorkingDir: Env:[HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=koye TERM=xterm] Tty:true Namespaces:map[NEWIPC:true NEWNET:true NEWNS:true NEWPID:true NEWUTS:true NEWUSER:true] Capabilities:[CHOWN DAC_OVERRIDE FOWNER MKNOD NET_RAW SETGID SETUID SETFCAP SETPCAP NET_BIND_SERVICE SYS_CHROOT KILL] Networks:[0xc21004e310] Routes:[] Cgroups:0xc21000f6e0 AppArmorProfile: ProcessLabel: RestrictSys:true UidMappings:[{ContainerId:0 HostId:1013 Size:1} {ContainerId:1 HostId:1 Size:1012}] GidMappings:[{ContainerId:0 HostId:1013 Size:1} {ContainerId:1 HostId:1 Size:1012}]}
2014/06/26 21:50:00 1
2014/06/26 21:50:00 proc: &{6 0 0}
2014/06/26 21:50:00 uid: [{ContainerId:0 HostId:1013 Size:1} {ContainerId:1 HostId:1 Size:1012}]
2014/06/26 21:50:00 0 1013 1
1 1 1012
2014/06/26 21:50:00 0 1013 1
1 1 1012
@mrunalp
mrunalp / container.json
Created June 24, 2014 23:04
userns config
{"mount_config":{"mounts":[{"type":"bind","source":"/var/lib/docker/init/dockerinit-1.0.1-dev","destination":"/.dockerinit","private":true},{"type":"bind","source":"/etc/resolv.conf","destination":"/etc/resolv.conf","private":true},{"type":"bind","source":"/var/lib/docker/containers/ff17757403e4b96fbb7a65dafe2dc8a3a21e809e3fa30e5d35d4f767fae267d3/hostname","destination":"/etc/hostname","private":true},{"type":"bind","source":"/var/lib/docker/containers/ff17757403e4b96fbb7a65dafe2dc8a3a21e809e3fa30e5d35d4f767fae267d3/hosts","destination":"/etc/hosts","private":true}],"device_nodes":[{"type":99,"path":"/dev/fuse","major_number":10,"minor_number":229,"cgroup_permissions":"rwm"},{"type":99,"path":"/dev/null","major_number":1,"minor_number":3,"cgroup_permissions":"rwm","file_mode":438},{"type":99,"path":"/dev/zero","major_number":1,"minor_number":5,"cgroup_permissions":"rwm","file_mode":438},{"type":99,"path":"/dev/full","major_number":1,"minor_number":7,"cgroup_permissions":"rwm","file_mode":438},{"type":99,"path
@mrunalp
mrunalp / userns_config.js
Created June 24, 2014 23:01
userns config
{"mount_config":{"mounts":[{"type":"bind","source":"/var/lib/docker/init/dockerinit-1.0.1-dev","destination":"/.dockerinit","private":true},{"type":"bind","source":"/etc/resolv.conf","destination":"/etc/resolv.conf","private":true},{"type":"bind","source":"/var/lib/docker/containers/ff17757403e4b96fbb7a65dafe2dc8a3a21e809e3fa30e5d35d4f767fae267d3/hostname","destination":"/etc/hostname","private":true},{"type":"bind","source":"/var/lib/docker/containers/ff17757403e4b96fbb7a65dafe2dc8a3a21e809e3fa30e5d35d4f767fae267d3/hosts","destination":"/etc/hosts","private":true}],"device_nodes":[{"type":99,"path":"/dev/fuse","major_number":10,"minor_number":229,"cgroup_permissions":"rwm"},{"type":99,"path":"/dev/null","major_number":1,"minor_number":3,"cgroup_permissions":"rwm","file_mode":438},{"type":99,"path":"/dev/zero","major_number":1,"minor_number":5,"cgroup_permissions":"rwm","file_mode":438},{"type":99,"path":"/dev/full","major_number":1,"minor_number":7,"cgroup_permissions":"rwm","file_mode":438},{"type":99,"path
[root@localhost ~]# docker run -it --rm busybox /bin/sh
/ # command -v groupadd
/ # echo $?
127
/ # addgroup -g 1003 container
/ # echo $?
0
/ # adduser -u 1003 -g 1003 container
adduser: uid '1003' in use
/ # echo $?
[root@localhost ~]# docker run -it --rm busybox /bin/sh
/ # command -v groupadd
/ # echo $?
127
/ # addgroup -g 1003 container
/ # echo $?
0
/ # adduser -u 1003 -g 1003 container
adduser: uid '1003' in use
/ # echo $?
package main
import (
"log"
"os"
"syscall"
)
func main() {
syscall.ForkLock.Lock()
@mrunalp
mrunalp / ip_adress.rb
Created March 18, 2014 21:03
Get IP address for an interface in ruby.
require 'socket'
require 'ipaddr'
# From ioctls.h
SIOCGIFADDR = 0x8915
def ip_address(iface)
sock = UDPSocket.new
buf = [iface,""].pack('a16h16')
sock.ioctl(SIOCGIFADDR, buf);
#!/usr/bin/env node
var WebSocketClient = require('websocket').client;
var client = new WebSocketClient();
client.on('connectFailed', function(error) {
console.log('Connect Error: ' + error.toString());
});
client.on('connect', function(connection) {
@mrunalp
mrunalp / gist:7570688
Created November 20, 2013 20:45
Supporting files
[mrunal@localhost nodejs]$ cat package.json
{
"name": "docker-fedora-nodejs",
"private": true,
"version": "0.0.1",
"description": "Node.js Hello World app on Fedora using docker",
"author": "Mrunal Patel <[email protected]>",
"dependencies": {
"express": "*"
}
# Base on the Fedora image created by Matthew
FROM mattdm/fedora
# Install the JBoss Application Server 7
RUN yum install -y nodejs npm
ADD . /src
RUN cd /src; npm install