docker pull

docker pullでDocker Indexからimageを持ってくる
Containerができる。docker runで実行する。
docker commitでImageを作る。
docker pushでDocker indexにimageが入る。
あ、docker indexはdocker hub

docker hub

コマンドラインからもsearchできる。
vagrant@vagrant-ubuntu-trusty-64:~$ sudo docker search centos | more

Imageが取得できたかどうかは、sudo docker imagesで確認できる。
vagrant@vagrant-ubuntu-trusty-64:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 4ab4c602aa5e 2 days ago 1.84kB
centos latest 5182e96772bf 4 weeks ago 200MB

sudo docker inspectで詳細を見ることができる。
vagrant@vagrant-ubuntu-trusty-64:~$ sudo docker inspect centos:latest
[
{
“Id”: “sha256:5182e96772bf11f4b912658e265dfe0db8bd314475443b6434ea708784192892”,
“RepoTags”: [
“centos:latest”
],
“RepoDigests”: [
“centos@sha256:6f6d986d425aeabdc3a02cb61c02abb2e78e57357e92417d6d58332856024faf”
],
“Parent”: “”,
“Comment”: “”,
“Created”: “2018-08-06T19:21:48.235227329Z”,
“Container”: “d60ffc9ddd12462af4bdcdbe45b74f3b3f99b46607ada80c3ed877b7def84250”,
“ContainerConfig”: {
“Hostname”: “d60ffc9ddd12”,
“Domainname”: “”,
“User”: “”,
“AttachStdin”: false,
“AttachStdout”: false,
“AttachStderr”: false,
“Tty”: false,
“OpenStdin”: false,
“StdinOnce”: false,
“Env”: [
“PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
],
“Cmd”: [
“/bin/sh”,
“-c”,
“#(nop) “,
“CMD [\”/bin/bash\”]”
],
“ArgsEscaped”: true,
“Image”: “sha256:748eacc0f236df2fc9ba87c4d76a66cb10742120387e99e2acdb9454915c841d”,
“Volumes”: null,
“WorkingDir”: “”,
“Entrypoint”: null,
“OnBuild”: null,
“Labels”: {
“org.label-schema.build-date”: “20180804”,
“org.label-schema.license”: “GPLv2”,
“org.label-schema.name”: “CentOS Base Image”,
“org.label-schema.schema-version”: “1.0”,
“org.label-schema.vendor”: “CentOS”
}
},
“DockerVersion”: “17.06.2-ce”,
“Author”: “”,
“Config”: {
“Hostname”: “”,
“Domainname”: “”,
“User”: “”,
“AttachStdin”: false,
“AttachStdout”: false,
“AttachStderr”: false,
“Tty”: false,
“OpenStdin”: false,
“StdinOnce”: false,
“Env”: [
“PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
],
“Cmd”: [
“/bin/bash”
],
“ArgsEscaped”: true,
“Image”: “sha256:748eacc0f236df2fc9ba87c4d76a66cb10742120387e99e2acdb9454915c841d”,
“Volumes”: null,
“WorkingDir”: “”,
“Entrypoint”: null,
“OnBuild”: null,
“Labels”: {
“org.label-schema.build-date”: “20180804”,
“org.label-schema.license”: “GPLv2”,
“org.label-schema.name”: “CentOS Base Image”,
“org.label-schema.schema-version”: “1.0”,
“org.label-schema.vendor”: “CentOS”
}
},
“Architecture”: “amd64”,
“Os”: “linux”,
“Size”: 199716491,
“VirtualSize”: 199716491,
“GraphDriver”: {
“Data”: {
“DeviceId”: “7”,
“DeviceName”: “docker-8:1-263323-d5a0c73632bbe71e2ab66b6f6d04da6bca10076e1f9f787ba6adcf10844a9b67”,
“DeviceSize”: “10737418240”
},
“Name”: “devicemapper”
},
“RootFS”: {
“Type”: “layers”,
“Layers”: [
“sha256:1d31b5806ba40b5f67bde96f18a181668348934a44c9253b420d5f04cfb4e37a”
]
},
“Metadata”: {
“LastTagTime”: “0001-01-01T00:00:00Z”
}
}
]

set up the repository for docker

公式を参考にします。
https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-from-a-package

$ sudo apt-get update

$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common

vagrant@vagrant-ubuntu-trusty-64:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
OK

vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-key fingerprint 0EBFCD88
/etc/apt/trusted.gpg
——————–
pub 1024D/437D05B5 2004-09-12
Key fingerprint = 6302 39CC 130E 1A7F D81A 27B1 4097 6EAF 437D 05B5
uid Ubuntu Archive Automatic Signing Key
sub 2048g/79164387 2004-09-12

pub 1024D/FBB75451 2004-12-30
Key fingerprint = C598 6B4F 1257 FFA8 6632 CBA7 4618 1433 FBB7 5451
uid Ubuntu CD Image Automatic Signing Key

pub 4096R/C0B21F32 2012-05-11
Key fingerprint = 790B C727 7767 219C 42C8 6F93 3B4F E6AC C0B2 1F32
uid Ubuntu Archive Automatic Signing Key (2012)

pub 4096R/EFE21092 2012-05-11
Key fingerprint = 8439 38DF 228D 22F7 B374 2BC0 D94A A3F0 EFE2 1092
uid Ubuntu CD Image Automatic Signing Key (2012)

pub 4096R/0EBFCD88 2017-02-22
Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid Docker Release (CE deb)
sub 4096R/F273FCD8 2017-02-22

sudo add-apt-repository \
“deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable”

さあ、遂にdockerを入れていきます。
$ sudo apt-get install docker-ce

vagrant@vagrant-ubuntu-trusty-64:~$ sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/

vagrant@vagrant-ubuntu-trusty-64:~$ docker –version
Docker version 18.06.1-ce, build e68fc7a

OKKKKKKKKKKKKKKKKKKKKKKKKKKKK!

ubuntuを入れていこう

まずvagrant box
https://www.vagrantbox.es/

まず、trustyをひっぱってくる
vagrant box add trusty64 https://github.com/sepetrov/trusty64/releases/download/v0.0.5/trusty64.box

cd trusty

vagrant init trusty64

vagrant file line54
config.vm.network “private_network”, ip: “192.168.55.44”

login as: vagrant
vagrant@192.168.55.44’s password:
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-100-generic x86_64)

* Documentation: https://help.ubuntu.com/

System information as of Mon Sep 10 00:10:54 UTC 2018

System load: 0.57 Processes: 75
Usage of /: 3.5% of 39.34GB Users logged in: 0
Memory usage: 26% IP address for eth0: 10.0.2.15
Swap usage: 0% IP address for eth1: 192.168.55.44

Graph this data and manage this system at:
https://landscape.canonical.com/

Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud

New release ‘16.04.5 LTS’ available.
Run ‘do-release-upgrade’ to upgrade to it.

OK!

apt-get updateする。
vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-get update
vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-get update
Ign http://archive.ubuntu.com trusty InRelease
Get:1 http://security.ubuntu.com trusty-security InRelease [65.9 kB]
Get:2 http://archive.ubuntu.com trusty-updates InRelease [65.9 kB]
Get:3 http://security.ubuntu.com trusty-security/main Sources [162 kB]
Get:4 http://archive.ubuntu.com trusty-backports InRelease [65.9 kB]
Get:5 http://security.ubuntu.com trusty-security/universe Sources [80.4 kB]
Hit http://archive.ubuntu.com trusty Release.gpg
Get:6 http://security.ubuntu.com trusty-security/main amd64 Packages [765 kB]
Get:7 http://archive.ubuntu.com trusty-updates/main Sources [422 kB]
Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [246 kB]
Get:9 http://archive.ubuntu.com trusty-updates/restricted Sources [6,322 B]
Get:10 http://archive.ubuntu.com trusty-updates/universe Sources [208 kB]
Get:11 http://archive.ubuntu.com trusty-updates/multiverse Sources [7,441 B]
Get:12 http://security.ubuntu.com trusty-security/main Translation-en [413 kB]
Get:13 http://archive.ubuntu.com trusty-updates/main amd64 Packages [1,101 kB]
Get:14 http://security.ubuntu.com trusty-security/universe Translation-en [134 kB]
Get:15 http://archive.ubuntu.com trusty-updates/restricted amd64 Packages [17.2 kB]
Get:16 http://archive.ubuntu.com trusty-updates/universe amd64 Packages [474 kB]
Get:17 http://archive.ubuntu.com trusty-updates/multiverse amd64 Packages [14.6 kB]
Get:18 http://archive.ubuntu.com trusty-updates/main Translation-en [547 kB]
Get:19 http://archive.ubuntu.com trusty-updates/multiverse Translation-en [7,616 B]
Get:20 http://archive.ubuntu.com trusty-updates/restricted Translation-en [4,021 B]
Get:21 http://archive.ubuntu.com trusty-updates/universe Translation-en [253 kB]
Get:22 http://archive.ubuntu.com trusty-backports/main Sources [9,709 B]
Get:23 http://archive.ubuntu.com trusty-backports/restricted Sources [28 B]
Get:24 http://archive.ubuntu.com trusty-backports/universe Sources [35.4 kB]
Get:25 http://archive.ubuntu.com trusty-backports/multiverse Sources [1,896 B]
Get:26 http://archive.ubuntu.com trusty-backports/main amd64 Packages [13.3 kB]
Get:27 http://archive.ubuntu.com trusty-backports/restricted amd64 Packages [28 B]
Get:28 http://archive.ubuntu.com trusty-backports/universe amd64 Packages [43.1 kB]
Get:29 http://archive.ubuntu.com trusty-backports/multiverse amd64 Packages [1,567 B]
Get:30 http://archive.ubuntu.com trusty-backports/main Translation-en [7,503 B]
Get:31 http://archive.ubuntu.com trusty-backports/multiverse Translation-en [1,215 B]
Get:32 http://archive.ubuntu.com trusty-backports/restricted Translation-en [28 B]
Get:33 http://archive.ubuntu.com trusty-backports/universe Translation-en [36.8 kB]
Hit http://archive.ubuntu.com trusty Release
Get:34 http://archive.ubuntu.com trusty/main Sources [1,064 kB]
Get:35 http://archive.ubuntu.com trusty/restricted Sources [5,433 B]
Get:36 http://archive.ubuntu.com trusty/universe Sources [6,399 kB]
Get:37 http://archive.ubuntu.com trusty/multiverse Sources [174 kB]
Hit http://archive.ubuntu.com trusty/main amd64 Packages
Hit http://archive.ubuntu.com trusty/restricted amd64 Packages
Hit http://archive.ubuntu.com trusty/universe amd64 Packages
Hit http://archive.ubuntu.com trusty/multiverse amd64 Packages
Hit http://archive.ubuntu.com trusty/main Translation-en
Hit http://archive.ubuntu.com trusty/multiverse Translation-en
Hit http://archive.ubuntu.com trusty/restricted Translation-en
Hit http://archive.ubuntu.com trusty/universe Translation-en
Ign http://archive.ubuntu.com trusty/main Translation-en_US
Ign http://archive.ubuntu.com trusty/multiverse Translation-en_US
Ign http://archive.ubuntu.com trusty/restricted Translation-en_US
Ign http://archive.ubuntu.com trusty/universe Translation-en_US
Fetched 12.9 MB in 50s (255 kB/s)
Reading package lists… Done

なんだ、Docker CEって。。

あ、CE…無償のコミュニティエディション
なるほど

久しぶりにperlを触ってみる

[vagrant@localhost perl]$ vi hello_world.pl
[vagrant@localhost perl]$ ls
hello.pl  hello_world.pl  test.dat
[vagrant@localhost perl]$ chmod 755 hello_world.pl
[vagrant@localhost perl]$ ls
hello.pl  hello_world.pl  test.dat
[vagrant@localhost perl]$ ./hello_world.pl
hello, world!
[vagrant@localhost perl]$ perl -e 'print "hello_world\n";'
hello_world

さーどうしようか。。とりあえず思い出すまで基礎かな。

tomcatにデプロイ

[vagrant@localhost apache-tomcat-8.5.33]$ sudo chmod 777 webapps

デプロイとは、WebアプリケーションをWebコンテナにインストール
tomcatがインストールされているwebappsフォルダにwarファイルをコピーすると、アプリケーションが動作可能になる。

こりゃ素人には無理だな。ちゃんと勉強しないと、立ち行きできんわ。

centosにtomcatを入れる

/optにtomcatのディレクトリを作成します。

[vagrant@localhost opt]$ ls
VBoxGuestAdditions-5.1.26 chef gradle mono monodevelop
[vagrant@localhost opt]$ sudo mkdir tomcat
[vagrant@localhost opt]$ ls
VBoxGuestAdditions-5.1.26 chef gradle mono monodevelop tomcat

どうやら、v8.5.33が新しいそうなので、8.5.33をwgetします。
[vagrant@localhost tomcat]$ sudo wget http://ftp.meisei-u.ac.jp/mirror/apache/dist/tomcat/tomcat-8/v8.5.33/bin/apache-tomcat-8.5.33.tar.gz
–2018-09-09 21:37:54– http://ftp.meisei-u.ac.jp/mirror/apache/dist/tomcat/tomcat-8/v8.5.33/bin/apache-tomcat-8.5.33.tar.gz
ftp.meisei-u.ac.jp をDNSに問いあわせています… 160.194.204.25
ftp.meisei-u.ac.jp|160.194.204.25|:80 に接続しています… 接続しました。
HTTP による接続要求を送信しました、応答を待っています… 200 OK
長さ: 9621331 (9.2M) [application/x-gzip]
`apache-tomcat-8.5.33.tar.gz’ に保存中

100%[======================================>] 9,621,331 175K/s 時間 37s

2018-09-09 21:38:31 (256 KB/s) – `apache-tomcat-8.5.33.tar.gz’ へ保存完了 [9621331/9621331]

[vagrant@localhost tomcat]$ ls
apache-tomcat-8.5.33.tar.gz

アーカイブファイルを展開する
[vagrant@localhost tomcat]$ sudo tar xvf apache-tomcat-8.5.33.tar.gz
[vagrant@localhost tomcat]$ ls
apache-tomcat-8.5.33 apache-tomcat-8.5.33.tar.gz

[vagrant@localhost ~]$ cd /etc/profile.d
[vagrant@localhost profile.d]$ ls
colorls.csh cvs.sh gnat-project.csh lang.csh less.sh which2.sh
colorls.sh glib2.csh gnat-project.sh lang.sh vim.csh
cvs.csh glib2.sh gradle.sh less.csh vim.sh
[vagrant@localhost profile.d]$ sudo vi tomcat.sh

これでいいのか??

JRE_HOME=/usr/bin/java
CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.33
export JRE_HOME CATALINA_HOME

うお、tomcat started.ってなってる!?
[vagrant@localhost apache-tomcat-8.5.33]$ sudo /opt/tomcat/apache-tomcat-8.5.33/bin/startup.sh
Using CATALINA_BASE: /opt/tomcat/apache-tomcat-8.5.33
Using CATALINA_HOME: /opt/tomcat/apache-tomcat-8.5.33
Using CATALINA_TMPDIR: /opt/tomcat/apache-tomcat-8.5.33/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/tomcat/apache-tomcat-8.5.33/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-8.5.33/bin/tomcat-juli.jar
Tomcat started.

iptableのポート設定
[vagrant@localhost profile.d]$ iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT

うおおおおおおおおおおおおおおおおおおおおおおおおおおおおおおおおおおおおおおおおお

怖くなったので、撤退
[vagrant@localhost profile.d]$ sudo /opt/tomcat/apache-tomcat-8.5.33/bin/shutdown.sh
Using CATALINA_BASE: /opt/tomcat/apache-tomcat-8.5.33
Using CATALINA_HOME: /opt/tomcat/apache-tomcat-8.5.33
Using CATALINA_TMPDIR: /opt/tomcat/apache-tomcat-8.5.33/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/tomcat/apache-tomcat-8.5.33/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-8.5.33/bin/tomcat-juli.jar

Java Servletとは

Java Servletは、業務用のWEBシステムを開発するときに幅広く利用されている

>Java Servlet(ジャバ サーブレット)とは、サーバ上でウェブページなどを動的に生成したりデータ処理を行うために、Javaで作成されたプログラム及びその仕様である。単にサーブレットと呼ばれることが多い。

サーブレット自体は、WEBページをはじめとし画面に関する処理はいっさい行わず、WEBブラウザからの要求に応えたり、送られてきたデータを処理したりする役割をする。

サーブレット単独では、WEBアプリ作成するための機能が不十分なので、後述する「JSP」や「Tomcat」と呼ばれる他のプログラムと連携してアプリを作る必要がある。

ライフサイクルとは、処理が始まってから終了するまでの一連の流れ
サーブレットは、このライフサイクルを管理する機能をもっていて、効率よく仕事をするようにできている。

通常は、一連の処理が完了したらそれまでに使ったデータを破棄してしまいます。
しかし、サーブレットは一連の処理が終わっても、データを保持して再利用できるようにする。最初の1回目は処理に時間がかかりますが、2回目はデータを再利用するので処理が早くなる。

マルチスレッドに対応
プラットフォームに依存しない

「JSP (JSP)」 は、HTML内にJavaのコードを埋め込み、動的にWEBページを生成する技術のことです。サーブレットはWEBアプリ内部の処理を担当していますが、JSPは主にWEBページを担当しています。サーブレットとJSPが連携することで、動的にWEBページを作ることが可能になります。

Tomcat
Tomcatは、サーブレットを動かすソフトの1つ
Tomcatはサーブレットを動かすエンジンの役割をしていて、必要に応じて命令を出してサーブレットを動かす

CentOS + Tomcat

まずJavaのversionから

[vagrant@localhost ~]$ java -version
openjdk version “1.8.0_171”
OpenJDK Runtime Environment (build 1.8.0_171-b10)
OpenJDK 64-Bit Server VM (build 25.171-b10, mixed mode)

ふむ。
続いて、Tomcatを入れたい。

Tomcatとは?
->ソフトウェア
->Java Servletを動かすときに使う
->簡易的なWebサーバーの機能も付いている

Java Servletを動かすときに必要なソフト(サーブレットコンテナ)のひとつ
Javaはプログラミング言語
「Webサーバ上で動くJavaプログラム」を「Java Servlet(サーブレット、Servlet)」と言う
サーブレットコンテナさんが、Java Servletさんを、ちまちま動かす
サーブレットコンテナと呼ばれるソフトは、いろいろあり、その「いろいろあるサーブレットコンテナのひとつ」が「Apache Tomcat」
Java Servletの動作確認ができるように(簡易的な)Webサーバとしての機能も持っている。

Tomcat:サーブレットコンテナ
Apache:Webサーバ

本格的にやるときはApacheとTomcatを連携させて両方使う
サーブレットコンテナとしてのお仕事はTomcatが行う

Tomcatとは?
サーブレットコンテナ(Java Serveletを動かすソフト)。
正式名称は「Apache Tomcat」。
初版は1999年。
最新バージョンは8.5。
簡易的なWebサーバとしての機能も持つ。

Java Servletを動かすためのソフト。
サーバ上で動くJavaプログラム 。動的なページが生成可能。

Scrum Allianceとは

アジャイル開発手法には複数の手法あるいはプラクティスと呼ばれるものがありますが、その中で「スクラム」はもっともよく使われている手法として知られており、マイクロソフトやIBMをはじめ多くの企業がソフトウェア開発の現場で採用している。

そのスクラムを実践するための「スクラムガイド(Scrum Guide in Japanese)」が、スクラムの普及促進のための団体「Scrum Alliance」から公開

スクラム入門
正しくは、様々なプロセスや技術を取り込むことのできるフレームワークである。スクラムの役割は、複雑なプロダクト開発が可能なフレームワークを提供することで、開発プラクティスの効果を相対的に浮き彫りにし、改善することである。

スクラムの内容
スクラムフレームワークは、スクラムチームとその役割、タイムボックス、成果物、およびルールで構成される。
スクラムチームは、柔軟性と生産性の最適化を目指すものである。チームは、自己組織化しており、クロスファンクショナルであり、反復的に作業をする。
(略)
スクラムがタイムボックスを採用しているのは、規則的なリズムをつけるためである。タイムボックスには、リリース計画ミーティング、スプリント計画ミーティング、スプリント、デイリースクラム、スプリントレビュー、スプリントレトロスペクティブが含まれる。
(略)
ルールは、スクラムのタイムボックス、役割、および成果物を結びつけるものである。

—–
スクラム(英: Scrum)は、ソフトウェア開発における反復的で漸進的なアジャイルソフトウェア開発手法の1つである。この方法論は「柔軟かつ全人的なプロダクト開発ストラテジーであり、共通のゴールに到達するため、開発チームが一体となって働くこと」とされる。この方法論は、製品開発における伝統的な、シーケンシャルなアプローチとは大きく異なる。この方法論は、チームが自発的に組織だって行動することを可能にする。この自己組織化を実現するのは、すべてのチームメンバーが物理的に同じ場所にいること、あるいは密なオンライン共同作業を通じ、全員が日々直接会ってお互いにコミュニケーションをとり、プロジェクトにおける規律を守ることである。

スクラムのカギとなる基本原則は、プロジェクト開発の途中で、顧客は、要求や必要事項を変えられるという認識である。予想できない変更について、計画に基づく方法で対処することは、容易ではない。したがって、スクラムは経験に基づくアプローチを採用する。問題を十分に理解することも、定義することもできないので、現れた要求へ素早く対応するためのチームの能力を最大化することに集中する、というアプローチである。
—–

開発途中での仕様変更を認めるということでしょうか。こういう資格があること自体知らんかった。

modelを編集していく

app直下のcomment.php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Comment extends Model
{
    //
    protected $fillable = ['body'];

    // $comment->post
    public function(){
    	return $this->belongsTo('App\Post');
    	
    }
}

post.php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    //
    protected $fillable = ['title', 'body'];

    public function comments(){
    	return $this->hasMany('App\Comment');
    }
}
<h2>Comments</h2>
<ul>
	@forelse ($post->comments as $comment)
	<li>
		{{ $comment->body }}
	</li>
	@empty
	<li>No comments yet</li>
	@endforelse
</ul>
@endsection

しまったーーーーーーーーー ファイル保存する前にmigrateしてバグってしまった。
なんてことを。。
まぁ、Laravelに慣れる、という目的は少し達成したので良しとしよう。