0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

dind(docker in docker)のお供に lazydocker は有能かも

Last updated at Posted at 2025-01-31

背景

dind(docker in docker)を利用している時に、dockerのプロセス含めての監視ができずに苦戦していた。

0. structure

% tree . -L 2
.
├── Makefile
├── compose.yaml
├── dockerfile      # dind のcontainer
└── workspace       # dind ないのvolume
    ├── Makefile
    ├── api
    ├── compose.yaml
    └── tmp.node.dockerfile

3 directories, 6 files

1. dindを利用している時に辛いこと

どれほどCPUやvolume, networkが利用されているか判断がつきづらく、ために遅いと感じてしまっていた。

lazydockerは、A simple terminal UI for both docker and docker-compose, written in Go with the gocui library.通りにGUI visualizeしてくれる機能をもつ。

dindでdocker containerを利用した際に、CPUやmemoryの確認がよういになる。
nodeのcontainerを作成するとこんな感じ。

スクリーンショット 2025-01-31 20.21.09.png

dindのdocker container内に作成した、dockerのservice, container, images, volume, networkの確認を実施が可能です。

Hostで作成した、container

compose.yaml
services:
  dind_container:
    container_name: dind_container
    privileged: true
    build:
      context: .
      dockerfile: dockerfile
      args:
        WORKING_DIR: /workspace
    tty: true
    restart: on-failure:3
    volumes:
      - ./workspace:/workspace
ARG WORKING_DIR

FROM docker:dind

WORKDIR ${WORKDIR}

RUN apk add vim lazydocker

docker container内に作成した nodeのcontainer

workspace/tmp.node.dockerfile
ARG NODE_VERSION
ARG ALPINE_VERSION
ARG WORKING_DIR

FROM node:22.13-alpine3.21

WORKDIR $WORKING_DIR

RUN apk add git
workspace/compose.yaml
services:
  node_container:
    build:
      context: .
      dockerfile: tmp.node.dockerfile
      args:
        NODE_VERSION: 22.13
        ALPINE_VERSION: 3.21
        WORKING_DIR: /workspace
    tty: true
    restart: always
    ports:
      - "3000:3000"
    volumes:
      - .:/workspace

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?