22
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Docker の nsinit を CoreOS で試してみた

Posted at

Attaching to a container with Docker 0.9 and libcontainer を参考に CoreOS で nsinit を試してみました。

流れ

  1. Vagrant で CoreOS を起動する。
  2. 適当なイメージでコンテナを作成する。
  3. golang + gcc の環境が必要なので、toolbox を使う。
  4. nsinit をビルドする。
  5. nsinit を使ってコンテナにログインする。
$ vagrant init -m yungsang/coreos-alpha
$ vagrant up
$ vagrant ssh
   ______                ____  _____
  / ____/___  ________  / __ \/ ___/
 / /   / __ \/ ___/ _ \/ / / /\__ \
/ /___/ /_/ / /  /  __/ /_/ /___/ /
\____/\____/_/   \___/\____//____/
(alpha 349.0.0)
core@localhost ~ $ docker pull yungsang/busybox
core@localhost ~ $ docker run -d -p 8080:8080 yungsang/busybox nc -p 8080 -l -l -e echo hello world!
851e2caaea566342ca2d32bfbd6542041a07af6c2ff54f5cd82f6d1be23953e8
core@localhost ~ $ docker ps
CONTAINER ID        IMAGE                     COMMAND                CREATED             STATUS              PORTS                    NAMES
851e2caaea56        yungsang/busybox:latest   nc -p 8080 -l -l -e    9 minutes ago       Up 9 minutes        0.0.0.0:8080->8080/tcp   clever_wright
core@localhost ~ $ toolbox
Pulling repository fedora
3f2fed40e4b0: Download complete
64fd7993bcaf: Download complete
511136ea3c5a: Download complete
fd241224e9cf: Download complete
core-fedora
Spawning container core-fedora on /var/lib/toolbox/core-fedora. Press ^] three times within 1s to abort execution.
/etc/localtime is not a symlink, not updating container timezone.
[root@localhost ~]# curl -OL http://golang.org/dl/go1.2.2.linux-amd64.tar.gz
[root@localhost ~]# tar zxvf go1.2.2.linux-amd64.tar.gz
[root@localhost ~]# export GOROOT=$HOME/go
[root@localhost ~]# export PATH=$PATH:$GOROOT/bin
[root@localhost ~]# mkdir gocode
[root@localhost ~]# export GOPATH=$HOME/gocode
[root@localhost ~]# export PATH=$PATH:$GOPATH/bin
[root@localhost ~]# yum install -y git gcc
[root@localhost ~]# go get github.com/docker/libcontainer/nsinit
[root@localhost ~]# ls -l $GOPATH/bin
total 7904
-rwxr-xr-x 1 root root 8093520 Jun 18 19:35 nsinit
[root@localhost ~]# cd /media/root/var/lib/docker/execdriver/native/851e2caaea566342ca2d32bfbd6542041a07af6c2ff54f5cd82f6d1be23953e8
[root@localhost 851e2caaea566342ca2d32bfbd6542041a07af6c2ff54f5cd82f6d1be23953e8]# nsinit exec sh
/ # ps
PID   USER     COMMAND
    1 root     nc -p 8080 -l -l -e echo hello world!
    7 root     sh
   12 root     ps
/ # 
22
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?