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?

More than 5 years have passed since last update.

Dockerfileに書いた字をBashに表示する(初心者備忘録)

Last updated at Posted at 2020-02-09

#Dockerfileを作る
ファイルの場所は適当でよし、とりあえずディレクトリ(ここではmy_build)を作り、その中にDockerfileを作る

Bash.shell
$ mkdir my_build
↓
$ cd my_build
↓
$ touch Dockerfile
↓

#Dockerfileに書き込む
普通にファイルを開いて入力する

FROM ubuntu:18.04

CMD ["echo", "hello container"]

##Dockerの内容に基づいてコンテナイメージを作成
上の続きから。
-tはコンテナイメージの名前をつけられます。
ここでいうところのwinterfall/hello

Bash.shell
↓
$ docker build -t winterfall/hello:1.0.0 .
↓

#Dockerを実行
こうすることで、Dockerfileの["echo", "hello container"]の部分が実行されます。

Bash.shell
$ docker run winterfall/hello:1.0.0

>>> hello container

#参考書
[みんなのDocker/Kubernetes]
(https://www.amazon.co.jp/%E3%81%BF%E3%82%93%E3%81%AA%E3%81%AEDocker-Kubernetes-%E7%9F%B3%E6%BE%A4-%E5%9F%BA/dp/429710461X/ref=sr_1_1?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&keywords=%E3%81%BF%E3%82%93%E3%81%AA%E3%81%AEdocker&qid=1581247458&sr=8-1)

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?