Demonstration code for docker core knowledge workshop.
- プログラムを作る (ruby, js, python, php, bashなど)
console.log("Hello World");
- Dockerfileを作成する
FROM node:19.4.0
WORKDIR /app
COPY scripts/hello_world.js .
CMD node hello_world.js
- コンテナイメージをビルドする
docker build -t {イメージ名} .
- コンテナを起動する
docker run --rm {イメージ名}
- コンテナをレジストリーにpushする
docker push {イメージ名}
- イメージ名はスラッシュ(
/
)区切りの文字列で、形式が自由(h/e/l/l/oでも可能) - イメージ名の頭にレジストリのホスト名を付けることで、リモートレジストリと関連づける (例: my-registry.jp)
- レジストリのホスト名はデフォルトでDockerHubになる(docker.io)
- レジストリによって、イメージ名の書き方のルールがある