LoginSignup
2
1

More than 3 years have passed since last update.

podman in dockerで、みんなで仲良く共用計算機でdockerを使いたい

Posted at

podman in dockerを使う理由

Dockerを計算用途で使うとき、singularityを使いたくなります。ただ、singularityはsudo権限がないとbuildができないので、podman in dockerでみんなの作業用VM代わりに作業してもらうようにしました。

podmanって?

Redhatのdockerみたいなもので、daemonがないことが特徴だと思ってます。

使用のイメージ

使うときは、各VMにsshログインをして使うようにします。
VMは、使い捨て出来るようにして、scp等でファイルの移動を行います。

image.png

イメージの作成


FROM docker.io/library/docker:dind

RUN apk --update add \
    bash \
    py-pip \
    supervisor \
    openssh \
    curl \
    build-base \
    libffi-dev \
    && \
    rm -rf /var/cache/apk/*

RUN apk add python3-dev
RUN apk add --no-cache libressl-dev musl-dev libffi-dev
RUN pip install docker-compose
RUN mkdir -p /var/log/supervisor


RUN apk add --no-cache openssh openrc
RUN rc-update add sshd && rc-status
RUN mkdir -p /run/openrc/ && touch /run/openrc/softlevel
RUN ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa
RUN ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa

RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories

RUN apk add singularity

RUN sed -i '2s/^/bash -c "\/usr\/sbin\/sshd -D"\&\n/' /usr/local/bin/dockerd-entrypoint.sh


RUN apk add sudo


RUN echo -e "<password here>\n<password here>" | (adduser user -s /bin/bash)
RUN addgroup docker
RUN addgroup user docker
RUN addgroup user wheel
RUN echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

起動など

#!/bin/bash

count=7000
for i in 0 1 2 3 4 5 6 7 8 9;
do
    echo $i
    sudo podman run -d --privileged -p 777$i:22 dind-docker
done

コンテナ上で、イメージを作成して、singularity buildで.sifファイルを作って、それをscpでホームに移動することで利用することができます。

2
1
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
2
1