0
0

[備忘録] Docerの基本のキ

Last updated at Posted at 2024-02-23

1.はじめに

Dockerを少し勉強したので、学んだことを備忘録として残します。

2.Dockerとは

DockerはホストOS(ローカルの場合、windows macなど)上で新しいコンピューター(ホストOSとは別でOSをインストールし、アプリケーションもホストOSとは共有されない)を動かすことができるもの。
上記のようなものをコンテナと呼ばれる箱に入れて動かす。

3.Hello Worldしてみた

Dockerfile
#nginxをダウンロードする
FROM nginx:latest
#index.htmlを入れるためのディレクトリを作る
RUN mkdir -p /usr/share/nginx/html
# ローカルにあるindex.htmlを↑で作ったディレクトリに入れる
COPY index.html /usr/share/nginx/html
# nginxのポートを指定
EXPOSE 80
# daemon offにしてメインプロセスとして動かす
CMD [ "nginx","-g","daemon off;" ]

nginxの場合、静的コンテンツは/usr/share/nginx/htmlに入れるらしい

4.終わりに

今回は、Dockerを使ってHello Worldしてみました。
今後は、docker-compose等も学んでJavaアプリケーションをdocker上で動かしてみたいです。

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