Docker 19.03æ°æ©è½ (root権éä¸è¦åãGPU対å¿å¼·åãCLIãã©ã°ã¤ã³â¦)
NTTã®é ç°ã§ãã2019å¹´7æ23æ¥ã«å ¬éããããDocker 19.03ã®æ°æ©è½ããä¼ããã¾ãã2018å¹´11æ8æ¥ã«ãªãªã¼ã¹ãããDocker 18.09以æ¥ã8ã¶æã¶ãã®ãªãªã¼ã¹ã§ãã
root権éä¸è¦å
å¾æ¥ã®Dockerã¯ããã¹ãã®root権éã§ãã¼ã¢ã³(dockerd
)ãåä½ãããå¿
è¦ããã£ããããèå¼±æ§ãè¨å®ãã¹ãçªãããã¨ããã¹ãã®root権éã奪ãããæããããã¾ããã
Docker 19.03ã§ã¯ãérootã¦ã¼ã¶ã§ãã¼ã¢ã³ãå®è¡ã§ããããã«ãªãã¾ãã(Rootlessã¢ã¼ã)ã Rootlessã¢ã¼ããæå¹åãããã¨ã§ãä¸ä¸Dockerã«èå¼±æ§ãè¨å®ãã¹ããã£ã¦ããæ»æè ã«ãã¹ãã®root権éã奪åããããã¨ãé²ããã¨ãåºæ¥ã¾ãããã ããç¾æç¹ã§ã¯cgroupãå©ç¨ã§ããªããªã©ã®å¶ç´ãããã¾ãã
Rootlessã¢ã¼ãã®Dockerã¯ï¼ curl -fsSL https://get.docker.com/rootless | sh
ã³ãã³ã1è¡ã§ãã¦ã¼ã¶ã®ãã¼ã ãã£ã¬ã¯ããªå
ã« sudo
ç¡ãã§ç°¡åã«ã¤ã³ã¹ãã¼ã«åºæ¥ã¾ããWebãã©ã¦ã¶å
ã§è©¦ç¨ãããã¨ãå¯è½ã§ãã
$ curl -fsSL https://get.docker.com/rootless | sh$ export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock$ docker run ...
Rootlessã¢ã¼ãã®è©³ç´°ã¯ã5æã«å·çããè¨äº Rootlessã¢ã¼ãã§Dockerãããå®å
¨ã«ãã[DockerConçºè¡¨ã¬ãã¼ã]
ãã覧ãã ããã
GPU対å¿å¼·å
å¾æ¥ã®Dockerã§NVIDIAã®GPUãç¨ããã«ã¯ã docker
ã³ãã³ãã®ä»£ããã« nvidia-docker
ã³ãã³ããç¨ããããOCIã©ã³ã¿ã¤ã ã¨ã㦠--runtime=nvidia
(nvidia-docker2) ãæå®ãããããå¿
è¦ãããã¾ããã
Docker 19.03ã§ã¯ãDockerèªä½ã«GPUé£æºæ©è½ docker run --gpus â¦
ãçµã¿è¾¼ã¾ãã¾ããã
$ docker run --gpus all
$ docker run --gpus 2,driver=nvidia,capabilities=compute
ç¾æç¹ã§ã¯ nvidia
ãã©ã¤ãã®ã¿ãå®è£
ããã¦ãã¾ãããå°æ¥çã«ã¯NVIDIA以å¤ã®ãã³ãã®GPUåãã®ãã©ã¤ããå®è£
ããããã¨ãæå¾
ããã¾ãã
ãªãã nvidia
ãã©ã¤ããå©ç¨ããã«ã¯ã nvidia-container-cli
ããã¹ãä¸ã«ã¤ã³ã¹ãã¼ã«ããã¦ããå¿
è¦ãããã¾ãã
docker buildã®å¼·å
Docker 18.06ã«ã¦è©¦é¨çã«ãDocker 18.09ã«ã¦æ£å¼ã«æ¡ç¨ãããBuildKitã¢ã¼ã ( DOCKER_BUILDKIT=1 docker build
) ããä¸å±¤å¼·åããã¦ãã¾ãã
docker build --cache-from
docker build
ã¯ãã¬ã¸ã¹ããªä¸ã®ã¤ã¡ã¼ã¸ããã£ãã·ã¥ã¨ãã¦ç¨ãã( --cache-from
)ãã¨ãåºæ¥ã¾ããããããªãããDocker 18.06ã»18.09ã§ã¯ãBuildKitã¢ã¼ããæå¹ã§ããå ´åã --cache-from
ã«ã¤ã¡ã¼ã¸ãæå®ãããã¨ãåºæ¥ã¾ããã§ããã
Docker 19.03ã§ã¯ãBuildKitã¢ã¼ããæå¹ãªå ´åã§ãã--cache-from
ã«ã¤ã¡ã¼ã¸ãæå®åºæ¥ã¾ãããã ãã --cache-from
ã«æå®ããã¤ã¡ã¼ã¸ã¯ã --build-arg BUILDKIT_INLINE_CACHE=true
ãä»ãã¦ãã«ãããã¦ããå¿
è¦ãããã¾ãã
docker build --output
ãã«ãããã¤ã¡ã¼ã¸ã®å
容ãã --output
ã§æå®ãããã£ã¬ã¯ããªå
ã«æ¸ãåºããããã«ãªãã¾ããã
$ cat Dockerfile
FROM alpine
RUN apk add --no-cache figlet
RUN figlet hello > /helloFROM scratch
COPY --from=0 /hello /hello$ docker build --output ./out .$ ls -l out/
total 4
-rw-r--r-- 1 suda suda 138 Jul 1 20:41 hello$ cat out/hello
_ _ _
| |__ ___| | | ___
| '_ \ / _ \ | |/ _ \
| | | | __/ | | (_) |
|_| |_|\___|_|_|\___/
docker context
docker
ã³ãã³ãã®æ¥ç¶å
ãã¹ãããâcontextâã¨ãã¦ç®¡çã§ããããã«ãªãã¾ãããkubectl
ã®contextã¨ä¼¼ã¦ãã¾ãã
$ docker context create foo --docker "host=tcp://myserver:2376,ca=~/ca-file,cert=~/cert-file,key=~/key-file"
foo
Successfully created context "foo"$ docker context ls
NAME DESCRIPTION DOCKER ENDPOINT ...
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock
foo tcp://myserver:2376$ docker --context=foo run ...
CLIãã©ã°ã¤ã³
docker
ã³ãã³ãããã©ã°ã¤ã³ã§æ¡å¼µã§ããããã«ãªãã¾ããã /usr/lib/docker/cli-plugins
ã¾ã㯠~/.docker/cli-plugins
ã«ããã©ã°ã¤ã³ãã¤ã㪠docker-foo
ãé
ç½®ããã¨ã docker foo
ã¨ãã¦å®è¡ã§ããããã«ãªãã¾ãã
æ¢ã«æ°å¤ãã®ãã©ã°ã¤ã³ãå®è£ ã»å ¬éããã¦ãã¾ãã
docker buildx
docker buildx
ãã©ã°ã¤ã³ãã¤ã³ã¹ãã¼ã«ããã¨ãBuildKitãç¨ã㦠docker build
ã³ãã³ãã®æ©è½ãå¼·åãã docker buildx
ã³ãã³ããå©ç¨ã§ããããã«ãªãã¾ãã
docker buildx
ã¯ãBuildKitã¢ã¼ãã® docker build
( export DOCKER_BUILDKIT=1
)ã¨ããä¼¼ã¦ãã¾ãããããå
é²çãªæ©è½ãåãã¦ãã¾ãã
ä¾ãã°ã docker buildx
ãç¨ããã¨ã amd64
ã arm64
ãªã©è¤æ°ã®ã¢ã¼ããã¯ãã£ã«å¯¾å¿ããã¤ã¡ã¼ã¸ãç°¡åã«ãã«ããããã¨ãåºæ¥ã¾ããè¤æ°ã¢ã¼ããã¯ãã£ã«å¯¾å¿ããã¤ã¡ã¼ã¸ããã«ãããã«ã¯ã次ã®2ã¤ã®æ¹æ³ãããã¾ãã
- å
è¿°ã®
docker context
ã³ãã³ããç¨ãã¦ãã¢ã¼ããã¯ãã£æ¯ã«ãªã¢ã¼ãã®Dockerãã¹ããç»é²ãã - QEMU user-mode emulationãç¨ãã¦ã1å°ã®Dockerãã¹ãã§è¤æ°ã¢ã¼ããã¯ãã£ãã¨ãã¥ã¬ã¼ããã
æ§è½é¢ã§ã¯1.ã®æ¹æ³ãåªãã¦ãã¾ãããæ¬è¨äºã§ã¯ç°¡åãª2.ã®æ¹æ³ãç´¹ä»ãã¾ãã
ã¾ãã amd64
ã¢ã¼ããã¯ãã£ã®ãã¹ãã«ã¦ linuxkit/binfmt
ã¤ã¡ã¼ã¸ãprivilegedã¢ã¼ãã§èµ·åãããã¹ãã® /proc/sys/fs/binfmt_misc
ã«ãQEMU user-mode emulationã®ãã¤ããªãç»é²ãã¾ãã
$ docker run --rm --privileged linuxkit/binfmt:v0.7
$ ls -l /proc/sys/fs/binfmt_misc/
total 0
-rw-r--r-- 1 root root 0 Jul 2 17:04 qemu-aarch64
-rw-r--r-- 1 root root 0 Jul 2 17:04 qemu-arm
-rw-r--r-- 1 root root 0 Jul 2 17:04 qemu-ppc64le
-rw-r--r-- 1 root root 0 Jul 2 17:04 qemu-s390x
--w------- 1 root root 0 Jul 2 17:04 register
-rw-r--r-- 1 root root 0 Jul 2 17:04 status
ããã§ãLinuxã«ã¼ãã«ã¯ã amd64
以å¤ã®ã¢ã¼ããã¯ãã£ã®ãã¤ããªããQEMU user-mode emulationãç¨ãã¦CPUãã¨ãã¥ã¬ã¼ãããªããå®è¡ã§ããããã«ãªãã¾ãããªããä¸è¬çã«ãQEMUãã¨ãã¦èªç¥ããã¦ããQEMU full-system emulationã¨ç°ãªããVMã¯ä½æããã¾ããã
ç¶ãã¦ã docker buildx create
åã³ docker buildx inspect --bootstrap
ãç¨ãã¦ãBuildKitããã¯ã¨ã³ããèµ·åãã¾ãã
$ docker buildx create --use
epic_blackburn$ docker buildx inspect --bootstrap
...
Name: epic_blackburn0
...
Platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/arm/v6
ããã§ãdocker buildx build
ãç¨ãã¦ãè¤æ°ã¢ã¼ããã¯ãã£ã«å¯¾å¿ããã¤ã¡ã¼ã¸ããã«ãã»ããã·ã¥ã§ããããã«ãªãã¾ãã
$ docker buildx build -t example.com/foo --push --platform linux/amd64,linux/arm64 ...
docker buildx
ãã©ã°ã¤ã³ã¯ãDocker社ã«ãã https://github.com/docker/buildx ã«ã¦æä¾ããã¦ãã¾ããDocker for Mac/Winã«ã¯æ¨æºã§ä»å±ãã¾ãã
docker app
docker app
ãã©ã°ã¤ã³ã使ãã¨ã docker-compose.yml
åã³ã¤ã¡ã¼ã¸ãã1ã¤ã®Cloud Native Application Bundle (CNAB)ã«ã¾ã¨ãã¦ãã¬ã¸ã¹ããªã«ããã·ã¥ãããããã«ãããã§ããããã«ãªãã¾ãã
ä¾ã¨ãã¦ã example-voting-app.dockerapp
ãããã·ã¥ãã¦ã¿ã¾ãã
$ cat ./example-voting-app.dockerapp/docker-compose.yml
version: "3.6"services:
redis:
image: redis:alpine
ports:
- "6379:6379"
db:
image: postgres:9.4
ports:
- "5432:5432"
vote:
image: dockersamples/examplevotingapp_vote:before
ports:
- "${vote.port}:80"
deploy:
replicas: ${vote.replicas}
result:
image: dockersamples/examplevotingapp_result:before
ports:
- "${result.port}:80"
worker:
image: dockersamples/examplevotingapp_worker$ docker app push ./example-voting-app.dockerapp --platform linux/amd64 -t example.com/foo.dockerapp
ããã·ã¥ããã¢ããªã±ã¼ã·ã§ã³ãã³ãã«ã¯ã docker app render
ãç¨ãã¦ã docker-compose.yml
ã«å¾©å
ãããã¨ãã§ãã¾ãã ãã ããå
ã® docker-compose.yml
ã§æå®ããã¦ããDocker Hubä¸ã®ã¤ã¡ã¼ã¸ã§ã¯ãªãããã³ãã«ã«ã³ãã¼ãããã¤ã¡ã¼ã¸ãç¨ãããã¾ãã
$ docker app render example.com/foo.dockerapp
version: "3.6"
services:
db:
image: example.com/foo.dockerapp@sha256:4d915cbb7d4f93a8b1d73fc62496d0e1757599b0e1c567fd349fa9e47720f868
ports:
- mode: ingress
target: 5432
published: 5432
protocol: tcp
redis:
image: example.com/foo.dockerapp@sha256:98547c3529f6b02e3c789c8f4a96d6bb8469b9119150c955370753b93f9a67f2
ports:
- mode: ingress
target: 6379
published: 6379
protocol: tcp
result:
image: example.com/foo.dockerapp@sha256:83b568996e930c292a6ae5187fda84dd6568a19d97cdb933720be15c757b7463
ports:
- mode: ingress
target: 80
published: 60081
protocol: tcp
vote:
deploy:
replicas: 2
image: example.com/foo.dockerapp@sha256:8e64b18b2c87de902f2b72321c89b4af4e2b942d76d0b772532ff27ec4c6ebf6
ports:
- mode: ingress
target: 80
published: 60080
protocol: tcp
worker:
image: example.com/foo.dockerapp@sha256:55753a7b7872d3e2eb47f146c53899c41dcbe259d54e24b3da730b9acbff50a1
ã¢ããªã±ã¼ã·ã§ã³ãã³ãã«ã¯ã docker app install
ãç¨ãã¦ãSwarmãKubernetesã«ãããã¤ãããã¨ãå¯è½ã§ãããã ããKubernetesã¸ãããã¤ããã«ã¯ãCompose on Kubernetesãã¤ã³ã¹ãã¼ã«ããã¦ããå¿
è¦ãããã¾ãã
$ docker app install --orchestrator kubernetes example.com/foo.dockerapp
docker app
ãã©ã°ã¤ã³ã¯ãDocker社ã«ãã https://github.com/docker/app ã«ã¦æä¾ããã¦ãã¾ããDocker for Mac/Winã«ã¯æ¨æºã§ä»å±ãã¾ãã
docker wasm
docker wasm
ãã©ã°ã¤ã³ã使ãã¨ãWASMã¢ããªã±ã¼ã·ã§ã³ãDockerã³ã³ããã®ããã«æ±ããã¨ãã§ãã¾ãã
ä¾ãã°ã tonistiigi/hello
ã¤ã¡ã¼ã¸ã¯ã docker run
ã³ãã³ãã§èµ·åããã¨é常ã®ã³ã³ããã¨ãã¦å®è¡ãããdocker wasm run
ã³ãã³ãã§èµ·åããã¨WASMã©ã³ã¿ã¤ã (wasmtimeã¾ãã¯wasmer)ä¸ã§å®è¡ããã¾ãã(åè¿°ã® docker buildx
ãã©ã°ã¤ã³ãç¨ãã¦ããã«ããã©ãããã©ã¼ã ã¤ã¡ã¼ã¸ã¨ãã¦ãã«ãããã¦ãã¾ãã)
$ docker run tonistiigi/hello
Hello world, I am linux/amd64!$ docker wasm run tonistiigi/hello
Hello world, I am wasi/wasm!
ã¾ããdocker wasm run tonistiigi/viu:docker
ãå®è¡ããã¨ãé¢ç½ããã¢ç»åã表示ããã¾ãã
docker wasm
ãã©ã°ã¤ã³ã¯ãTõnis Tiigiæ°ã«ãã https://github.com/tonistiigi/wasm-cli-plugin ã«ã¦é
å¸ããã¦ãã¾ãã
docker expose
docker expose
ãã©ã°ã¤ã³ã使ãã¨ãngrokãç¨ãã¦ç°¡åã«ã³ã³ãããã¤ã³ã¿ã¼ãããã«å
¬éã§ãã¾ãã
$ docker run --name nginx -d nginx
$ docker expose nginx 80
...
https://deadbeef.ngrok.io
...
docker expose
ãã©ã°ã¤ã³ã¯ã Åukasz Lachæ°ã«ãã https://github.com/lukaszlach/clip ã«ã¦é
å¸ããã¦ãã¾ãã
docker microscan
docker microscan
ãã©ã°ã¤ã³ã使ãã¨ãAqua MicroScannerãç¨ãã¦ã¤ã¡ã¼ã¸ä¸ã®èå¼±æ§ãã¹ãã£ã³ã§ãã¾ãã
$ docker microscan debian
No critical vulnerabilities found in debian
docker microscan
ãã©ã°ã¤ã³ã¯ã docker expose
ãã©ã°ã¤ã³ã¨åããÅukasz Lachæ°ã«ããã https://github.com/lukaszlach/clip ã«ã¦é
å¸ããã¦ãã¾ãã
Enterprise Editionã®ãã©ã°ã¤ã³
Docker 19.03ããã¼ã¹ã¨ããã¨ã³ã¿ã¼ãã©ã¤ãºè£½åã§ããDocker Enterprise 3.0ã«ã¯ã docker assemble
ã docker template
ã docker cluster
ã docker gmsa
ã docker registry
ãªã©å¤ãã®ãã©ã°ã¤ã³ãä»å±ããããã§ãã
https://www.slideshare.net/ajeetraina/dockercon-2019-updates-announcements/26
ãããã«
ç§ãã¡NTTã¯ãªã¼ãã³ã½ã¼ã¹ã³ãã¥ããã£ã§å ±ã«æ´»åãã仲éãåéãã¦ãã¾ãããã²å¼ç¤¾ ã½ããã¦ã§ã¢ã¤ããã¼ã·ã§ã³ã»ã³ã¿ç´¹ä»ãã¼ã¸ããæ¡ç¨æ å ±ãã¼ã¸ãã覧ãã ããã