Docker

since 2018-07-10

Docker on WSL (Windows Subsystem for Linux)

setup

  • Windows 10 version 1803 (x64) Home
  • WSL Ubuntu 16.04

https://www.reddit.com/r/bashonubuntuonwindows/comments/8cvr27/docker_is_running_natively_on_wsl/

http://www.nuits.jp/entry/docker-on-wsl

書かれているとおりで環境構築、動作を確認

.bashrc の最後に cgroupfs-mount を追加

sudo systemctl enable docker を実行してサービスを自動起動

試せたこと

$ sudo docker run --rm hello-world

$ sudo docker run -it ubuntu bash

$ sudo docker run -it --rm -p 8080:80 nginx:latest

Python イメージという話

https://qiita.com/RyoMa_0923/items/7c0b22dd3f284472e18d

$ sudo docker pull python:3.6
$ sudo docker run -d --name hoge python:3.6 /bin/bash -c 'tail -f /dev/null'
$ sudo docker exec -it hoge /bin/bash
rpc error: code = 13 desc = invalid header field value "oci runtime error: exec failed: container_linux.go:247: starting container process caused \"could not create session key: function not implemented\"\n"

動いているようだが?

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
f207175bc4bb        python:3.6          "/bin/bash -c 'tai..."   2 minutes ago       Up About a minute                       hoge

もっと単純なことからやり直すか

$ sudo docker run -d --name hoge2 ubuntu /bin/bash -c 'tail -f /dev/null'

$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
64a1e42b1617        ubuntu              "/bin/bash -c 'tai..."   13 seconds ago      Up 5 seconds                            hoge2
f207175bc4bb        python:3.6          "/bin/bash -c 'tai..."   5 minutes ago       Up 5 minutes                            hoge

$ sudo docker exec -it hoge2 /bin/bash
rpc error: code = 13 desc = invalid header field value "oci runtime error: exec failed: container_linux.go:247: starting container process caused \"could not create session key: function not implemented\"\n"

そもそも docker run -d した環境に接続できない?

docker kill はできる

$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
64a1e42b1617        ubuntu              "/bin/bash -c 'tai..."   13 minutes ago      Up 13 minutes                           hoge2
f207175bc4bb        python:3.6          "/bin/bash -c 'tai..."   19 minutes ago      Up 19 minutes                           hoge

$ sudo docker kill hoge
hoge

$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
64a1e42b1617        ubuntu              "/bin/bash -c 'tai..."   13 minutes ago      Up 13 minutes                           hoge2

$ sudo docker kill hoge2
hoge2

$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Windows 再起動後

2018-07-11

再起動したらもういちど下記が必要らしい

(1) Ubuntu (16.04) を管理者で実行

sudo service docker start

(2) いったん閉じて、もう一度 Ubuntu (16.04) を管理者で実行

sudo cgroupfs-mount && sudo service docker start

確認

sudo docker run –rm hello-world

docker.txt · 最終更新: 2018/07/11 10:35 by Takuya Nishimoto
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0