Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
7
Help us understand the problem. What is going on with this article?
@yungsang

リベンジ: nsinit on boot2docker

More than 5 years have passed since last update.

docker - nsinit が上手く行かなくて困っていたら nsenter があまりにもあっさりだった件 - Qiita から一週間、試行錯誤を繰り返すこと幾度か。

RHEL/CentOS 6で Docker に nsinit/nsenter する - Qiita で、タグを指定することを教えてもらい、再度試すもエラーが続く。

今日、Docker v1.1.0 を出たことをキッカケに最新のコードで再度試すも上手く行かず、悩んだ末、golang からインストールすることに。

これがなんと大正解!
コードのバージョンの問題+tce-load -wil go でインストールされる go のバイナリのせいでもあることが判明しました。

以下成功した状態の Vagrantfile を残しておきます。
念の為、boot2docker v1.1.0~、libcontainer v1.1.0 に固定しました。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "boot2docker-nsinit"

  config.vm.box = "yungsang/boot2docker"

  config.vm.box_version = ">= 1.1.0, <= 1.1.1"

  config.vm.provision :shell do |s|
    s.privileged = false
    s.inline = <<-EOT
      tce-load -wil compiletc 2> /dev/null

      echo "Installing go"
      cd /tmp
      curl -sOL http://golang.org/dl/go1.3.linux-386.tar.gz
      cd /var/lib/boot2docker
      sudo tar zxf /tmp/go1.3.linux-386.tar.gz
      export GOROOT=/var/lib/boot2docker/go
      export PATH=$PATH:$GOROOT/bin

      echo "Installing nsinit"
      cd $HOME
      export GOPATH=$HOME/go
      go get -d github.com/docker/libcontainer/nsinit
      cd $GOPATH/src/github.com/docker/libcontainer
      git checkout -B nsinit v1.1.0
      cd $GOPATH/src/github.com/docker/libcontainer/nsinit
      go install .
      sudo cp -f $GOPATH/bin/nsinit /usr/local/bin/nsinit

      echo "Installing docker-nsinit"
      cd $HOME
      curl -sOL https://raw.githubusercontent.com/YungSang/docker-attach/master/docker-nsinit
      chmod +x docker-nsinit
      sudo mv docker-nsinit /usr/local/bin/docker-nsinit
    EOT
  end

  config.vm.provision :docker do |d|
    d.pull_images "yungsang/busybox"
    d.run "simple-echo",
      image: "yungsang/busybox",
      args: "-p 8080:8080",
      cmd: "nc -p 8080 -l -l -e echo hello world!"
  end

  config.vm.network :forwarded_port, guest: 8080, host: 8080
end
$ vagrant up
$ vagrant ssh
                        ##        .
                  ## ## ##       ==
               ## ## ## ##      ===
           /""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
           \______ o          __/
             \    \        __/
              \____\______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
boot2docker: 1.1.0
             nfs+nsenter : e012f67 - Thu Jul  3 22:12:51 UTC 2014
docker@boot2docker:~$ docker ps
CONTAINER ID        IMAGE                     COMMAND                CREATED              STATUS              PORTS                    NAMES
4e5e685e7b4d        yungsang/busybox:latest   nc -p 8080 -l -l -e    About a minute ago   Up About a minute   0.0.0.0:8080->8080/tcp   simple-echo
docker@boot2docker:~$ docker-nsinit 4e5e685e7b4d
cd /var/lib/docker/execdriver/native/4e5e685e7b4d4d02b1f36048638b6677b2d45af07362aeb123ad4767d45aa464 && nsinit exec -- /bin/sh
/ #

(゚∀゚)キタコレ!!

7
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
yungsang
Just another Otospermophilus beecheyi

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
7
Help us understand the problem. What is going on with this article?