Dockerで手元のイメージから派生したイメージを作る
Dockerで手元のイメージから派生したイメージを作る
BaseとなるDockerfile
Dockerfile
https://github.com/piuccio/cowsay を グローバルインストールしておく
FROM node:14
RUN npm install -g cowsay
ビルドしてcowsay-imageでタグ付けする
$ docker build -t cowsay-image .
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
cowsay-image latest 2d25113e504d 3 minutes ago 946MB
コンテナを立ち上げてbashに入って実際にcowsayがグローバルインストールしてあるか確認
$ docker run -it cowsay-image bash
root@8888888:/# cowsay hoge
______
< hoge >
------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
root@8888888:/#
Baseを元に派生したイメージを作成する
Dockerfile
ローカルで派生したイメージを作るにはFROMに先程作成したイメージ名を指定するだけ!!
FROM cowsay-image
CMD [ "cowsay", "hoge" ]
$ docker run -it evolution-cowsay
______
< hoge >
------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
CMDなどに設定するコマンドを色々試したい時
bashで色々試せるので、Baseイメージ内でコマンド打って検証する
$ docker run -it cowsay-image bash
root@ce25bb3685b6:/# cowsay
Usage: cowsay [-e eye_string] [-f cowfile] [-h] [-l] [-n] [-T tongue_string] [-W
column] [-bdgpstwy] text
If any command-line arguments are left over after all switches have been
processed, they become the cow's message.
If the program is invoked as cowthink then the cow will think its message
instead of saying it.
Options:
--version Show version number [boolean]
-e Select the appearance of the cow's eyes. [default: "oo"]
-T The tongue is configurable similarly to the eyes through -T and
tongue_string. [default: " "]
-W Specifies roughly where the message should be wrapped. The default
is equivalent to -W 40 i.e. wrap words at or before the 40th
column. [number] [default: 40]
-f Specifies a cow picture file (''cowfile'') to use. It can be
either a path to a cow file or the name of one of cows included in
the package. [default: "default"]
--think Think the message instead of saying it aloud. [boolean]
-b Mode: Borg [boolean]
-d Mode: Dead [boolean]
-g Mode: Greedy [boolean]
-p Mode: Paranoia [boolean]
-s Mode: Stoned [boolean]
-t Mode: Tired [boolean]
-w Mode: Wired [boolean]
-y Mode: Youthful [boolean]
-h, --help Show help [boolean]
-n If it is specified, the given message will not be word-wrapped.
[boolean]
-r Select a random cow [boolean]
-l List all cowfiles included in this package. [boolean]
root@ce25bb3685b6:/# cowsay -b fugo
______
< fugo >
------
\ ^__^
\ (==)\_______
(__)\ )\/\
||----w |
|| ||
root@ce25bb3685b6:/# cowsay -w fugo
______
< fugo >
------
\ ^__^
\ (OO)\_______
(__)\ )\/\
||----w |
|| ||
root@ce25bb3685b6:/# cowsay -y fugo
______
< fugo >
------
\ ^__^
\ (..)\_______
(__)\ )\/\
||----w |
|| ||
root@ce25bb3685b6:/# cowsay -t fugo
______
< fugo >
------
\ ^__^
\ (--)\_______
(__)\ )\/\
||----w |
|| ||
Author And Source
この問題について(Dockerで手元のイメージから派生したイメージを作る), 我々は、より多くの情報をここで見つけました https://qiita.com/taigamikami/items/0979098d6480689925cd著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .