LoginSignup
0
0

More than 1 year has passed since last update.

IIJ BootCamp Git をハンズオンしてみる(事前準備 Docker for win)

Posted at

37歳ですが、IIJの新入社員研修向け資料をやってみます。

概要

・Docker desktop for windowsをインストール
・Nginx (Webサーバ)入りのコンテナをrun
・コンテナを削除

参考文献

[1] IIJ 研修 https://eng-blog.iij.ad.jp/archives/15297
[2] 事前準備 https://iij.github.io/bootcamp/init/hello-bootcamp/
[2] GitHub入門 https://iij.github.io/bootcamp/development/github/

事前準備

私の環境

Linux環境
・ミニPC
・Ubuntu server 20.04
Docker Desktop環境
・メインPC + Terminal
image.png

以前Docker環境は建ててありました。
https://qiita.com/kanegae/items/673351b1568835aaad48
image.png

Docker desktop for windowsのインストール

PowerShell やコマンドプロンプトを開き、docker versionコマンドが実行できれば成功です

Power shellで docker version を打ってversiongが表示されたのでOK
image.png

hello-world コンテナを動かす

動いた。

PS C:\Users\skane> docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.

Nginx を立てて手元で HTML を書き換える

VIMがWinだと使えないので、メモ帳でhtmlファイルを書いた。
%CD%の表記だとエラーになったので、フルパスで書いたら通った。

$ vim content/index.html
vim: The term 'vim' is not recognized as a name of a cmdlet, function, script file, or executable program.
$ docker run --name test-nginx -p 8080:80 --mount type=bind,source=%CD%/content,target=/usr/share/nginx/html,ro -d nginx
docker: Error response from daemon: invalid mount config for type "bind": invalid mount path: '%CD%/content' mount path must be absolute.

修正後

$ docker run --name test-nginx -p 8080:80 --mount type=bind,source=C:\Users\skane\content,target=/usr/share/nginx/html,ro -d ngin
・・・
nable to find image 'nginx:latest' locally
latest: Pulling from library/nginx

ブラウザでHello worldが見れた!!
image.png

Docker コンテナのお掃除

stopしてrm。

$ docker stop test-nginx
$ docker rm test-nginx

test-nginxがなくなった。

docker images
REPOSITORY                                               TAG       IMAGE ID       CREATED         SIZE
nginx                                                    latest    88736fe82739   13 days ago     142MB
vsc-helloworld-django-6e218a36343300c01753310ec3140281   latest    6a0fb9e7ba50   3 months ago    1.27GB
hello-world                                              latest    feb5d9fea6a5   14 months ago   13.3kB

昔作った djangoのイメージファイルが大きいので消しておこう。
CUIからうまく消せなかったので、GUIから消した。
すっきり。
image.png

次回は GitHub入門にチャレンジ。

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