2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

とりあえずのDockerfileを作成したい。

Last updated at Posted at 2020-01-15

応用範囲が広いDockerfileのテンプレートを書いた。

僕はArchliluxが好きだ。つまりpacmanとaurが好きだ。archwikiとpkgbuildが好きだ。
それをそのままDockerに応用したい。そしてserverでもそのまま使いたいし、開発にも応用したい。

FROM archlinux/base
ARG PKG="yay"
RUN curl https://www.archlinux.org/mirrorlist/\?country\=JP\&protocol\=https\&ip_version\=4\&ip_version\=6 > /tmp/mirrorlist && sed -e "s/^#//g" /tmp/mirrorlist > /etc/pacman.d/mirrorlist && yes "" | pacman -Syy git base-devel
RUN useradd -m -s /bin/bash docker
RUN echo 'Defaults visiblepw'            >> /etc/sudoers
RUN echo 'docker ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

USER docker
WORKDIR /home/docker

## RUN sudo pacman -S $PKG
RUN git clone https://aur.archlinux.org/$PKG.git && cd $PKG && yes "" | makepkg -si && rm -r ~/$PKG

ENTRYPOINT ["bash", "-c", "echo editThisCommand."]

使い方

2行目を編集するだけ!AURじゃない場合普通にpacmanでインストールできます。コメントアウト等は適当に。
ARG PKG="samba"と書けばファイルサーバーになるし、ARG PKG="dnsmasq"と書けばDNSサーバーになります。

例えば

FROM archlinux/base
ARG PKG="samba"
RUN curl https://www.archlinux.org/mirrorlist/\?country\=JP\&protocol\=https\&ip_version\=4\&ip_version\=6 > /tmp/mirrorlist && sed -e "s/^#//g" /tmp/mirrorlist > /etc/pacman.d/mirrorlist && yes "" | pacman -Syy git base-devel
RUN useradd -m -s /bin/bash docker
RUN echo 'Defaults visiblepw'            >> /etc/sudoers
RUN echo 'docker ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# USER docker
# WORKDIR /home/docker

RUN pacman -S $PKG
## RUN git clone https://aur.archlinux.org/$PKG.git && cd $PKG && yes "" | makepkg -si && rm -r ~/$PKG

## https://wiki.archlinux.jp/index.php/Samba を参考に
RUN  curl "https://git.samba.org/samba.git/?p=samba.git;a=blob_plain;f=examples/smb.conf.default;hb=HEAD" > /etc/samba/smb.conf
RUN  yes "password" | pdbedit -a docker -t
RUN chmod 0777 /home/docker
ENTRYPOINT [ "bash", "-c", "nmbd -D && smbd -F </dev/null" ] ]
2
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?