この資料では、Docker for Windows を使って Windows OS 上で Linux ベースのアプリを開発する方法、そして Web アプリを含む Docker コンテナをクラウド環境(Azure 環境)に展開する方法について解説します。
※ 本資料では Docker の Linux コンテナのみを取り扱います。(Windows コンテナは取り扱いません。Windows OS で使い慣れたエディタや開発環境を使いつつ、Docker for Windows を活用して Linux 上でデバッグを行う、というシナリオを扱っています。)
※ 資料の概要は以下の blog エントリを参照してください。
https://blogs.msdn.microsoft.com/nakama/2018/09/27/dockerandazure/
コンテナ技術入門/Container tech intro
この資料は,2024年3月に開催される「高専テクノゼミ/実践教育プログラム vol.2」の技術LT「コンテナ技術入門」にて発表した際に使用したものです.
This document was used in a presentation at the technical LT "Introduction to Container Technology" of "Techno Seminar/Practical Education Program vol.2" to be held in March 2024.
Introducton to Convolutional Nerural Network with TensorFlowEtsuji Nakai
Explaining basic mechanism of the Convolutional Neural Network with sample TesnsorFlow codes.
Sample codes: https://github.com/enakai00/cnn_introduction
Machine Learning Basics for Web Application DevelopersEtsuji Nakai
This document provides an overview of machine learning basics for web application developers. It discusses linear binary classifiers and logistic regression, how to measure model fitness with loss functions, and graphical understandings of linear classifiers. It then covers linear multiclass classifiers using softmax functions, image classification with neural networks, and ways to improve accuracy using convolutional neural networks. Finally, it discusses client applications that use pre-trained machine learning models through API services and examples of smile detection and cucumber classification.
Your first TensorFlow programming with JupyterEtsuji Nakai
This document provides an introduction and overview of TensorFlow and how to use it with Jupyter notebooks on Google Cloud Platform (GCP). It explains that TensorFlow is Google's open source library for machine learning and was launched in 2015. It is used for many production machine learning projects. Jupyter is introduced as an interactive web-based platform for data analysis that can also be used as a TensorFlow runtime environment. The document then provides details on the programming paradigm and model of TensorFlow, giving an example of using it for a least squares method problem to predict temperatures. It explains the key components of defining a model, loss function, and training algorithm to optimize variables in a session.
This document provides an introduction to deep Q-networks (DQN) for beginners. It explains that DQNs can be used to learn optimal actions in video games by collecting data on screen states, player actions, rewards, and next states without knowing the game's rules. The key idea is to approximate a "Q function" that represents the total expected rewards if optimal actions are taken from each state onward. A deep neural network is used as the candidate function, and its parameters are adjusted using an error function to satisfy the Q-learning equation. To collect the necessary state-action data, the game is played with a mix of random exploration and exploiting the current best actions from the Q-network.
22. 22
OpenStack&Docker活用テクニック
MySQLのコンテナイメージ作成
Dockerfileを用いて、MySQLのコンテナイメージを作成します。
– Dockerfile一式をダウンロードして展開します。
– MySQLイメージ作成用のDockerfileを開いて、下記の部分を編集します。
– Dockerfileを用いてコンテナイメージを作成します。
# yum -y install git
# cd ~
# git clone https://github.com/enakai00/docker_eplite
# cd docker_eplite/build_epmysql
# vi Dockerfile
FROM 192.168.253.13:5000/library/centos:6.7
MAINTAINER Docker Tarou
RUN yum -y install mysql-server
ADD init.sh /usr/local/bin/init.sh
RUN chmod u+x /usr/local/bin/init.sh
EXPOSE 3306
CMD ["/usr/local/bin/init.sh"]
CentOS6.7のイメージを本環境の
プライベートレジストリーから取得
あなたの名前(任意)を記載します。
# docker build -t epmysql:ver1.0 ./
...(完成までしばらく待ちます)...
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
epmysql ver1.0 81700756f51a 11 minutes ago 339.3 MB
192.168.253.13:5000/library/centos 6.7 3fba1048142f 7 weeks ago 190.6 MB
23. 23
OpenStack&Docker活用テクニック
EP-Liteのコンテナイメージ作成
Dockerfileを用いて、EP-Liteのコンテナイメージを作成します。
– EP-Liteイメージ作成用のDockerfileを開いて、下記の部分を編集します。
– Dockerfileを用いてコンテナイメージを作成します。
# cd ~/docker_eplite/build_eplite
# vi Dockerfile
FROM 192.168.253.13:5000/library/centos:6.7
MAINTAINER Docker Tarou
ADD setup.sh /usr/local/bin/setup.sh
RUN chmod u+x /usr/local/bin/setup.sh
RUN /usr/local/bin/setup.sh
ADD settings.json /opt/etherpad/etherpad-lite/settings.json
ADD eplite.conf /etc/nginx/conf.d/eplite.conf
ADD etherpad-lite /etc/init.d/etherpad-lite
RUN chmod 755 /etc/init.d/etherpad-lite
ADD init.sh /usr/local/bin/init.sh
RUN chmod u+x /usr/local/bin/init.sh
CMD ["/usr/local/bin/init.sh"]
CentOS6.7のイメージを本環境の
プライベートレジストリーから取得
あなたの名前(任意)を記載します。
# docker build -t eplite:ver1.0 ./
...(完成までしばらく待ちます)...
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
epmysql ver1.0 81700756f51a 50 minutes ago 339.3 MB
eplite ver1.0 c48a3b84249b 11 minutes ago 729.1 MB
192.168.253.13:5000/library/centos 6.7 3fba1048142f 7 weeks ago 190.6 MB
24. 24
OpenStack&Docker活用テクニック
(参考)Dockerfileの処理内容:MySQLイメージ
#!/bin/bash
service mysqld start
if [[ ! -f ~/.trap_in_bashrc ]]; then
cat <<EOF >>~/.bashrc
trap 'service mysqld stop; exit 0' TERM
EOF
touch ~/.trap_in_bashrc
fi
if [[ ! -d /var/lib/mysql/epdb ]]; then
mysqladmin -u root password 'password'
cat << EOF > /tmp/sql.txt
DELETE FROM mysql.user WHERE user = '' OR ( user = 'root' AND host != 'localhost' );
FLUSH PRIVILEGES;
CREATE DATABASE epdb CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON epdb.* TO 'epuser'@'%' IDENTIFIED BY 'eppasswd';
FLUSH PRIVILEGES;
SELECT user, password, host FROM mysql.user;
EOF
mysql -uroot -ppassword < /tmp/sql.txt
fi
exec /bin/bash
FROM centos:6.7
MAINTAINER Etsuji Nakai
RUN yum -y install mysql-server
ADD init.sh /usr/local/bin/init.sh
RUN chmod u+x /usr/local/bin/init.sh
EXPOSE 3306
CMD ["/usr/local/bin/init.sh"]
Dockerfile
init.sh
MySQLをインストールして、
起動スクリプト init.sh をイメージ内にコピー
MySQLを起動
コンテナ停止時のMySQL停止処理を設定
データベース「epdb」が存在しなければ、作成して初期化する
bashを起動
init.shを起動スクリプトに指定
25. 25
OpenStack&Docker活用テクニック
(参考)Dockerfileの処理内容:Etherpad-Liteイメージ
#!/bin/bash -x
sed -i "s/__FIP__/${FIP}/" /etc/nginx/conf.d/eplite.conf
sed -i "s/__DBIP__/${DB_PORT_3306_TCP_ADDR}/" /opt/etherpad/etherpad-lite/settings.json
service etherpad-lite start
service nginx start
if [[ ! -f ~/.trap_in_bashrc ]]; then
cat <<EOF >>~/.bashrc
trap 'service nginx stop; service etherpad-lite stop; exit 0' TERM
EOF
touch ~/.trap_in_bashrc
fi
exec /bin/bash
FROM centos:6.7
MAINTAINER Etsuji Nakai
ADD setup.sh /usr/local/bin/setup.sh
RUN chmod u+x /usr/local/bin/setup.sh
RUN /usr/local/bin/setup.sh
ADD settings.json /opt/etherpad/etherpad-lite/settings.json
ADD eplite.conf /etc/nginx/conf.d/eplite.conf
ADD etherpad-lite /etc/init.d/etherpad-lite
RUN chmod 755 /etc/init.d/etherpad-lite
ADD init.sh /usr/local/bin/init.sh
RUN chmod u+x /usr/local/bin/init.sh
CMD ["/usr/local/bin/init.sh"]
Dockerfile
各種設定ファイルの雛形とEtherpad-Lite
起動スクリプトをイメージ内にコピー
Etherpad-Liteのインストールスクリプトを
イメージ内にコピーして実行
コンテナ停止時の
アプリケーション停止処理を設定
Etherpad-Liteとnginxを起動
bashを起動
init.shをイメージ内にコピーして
起動スクリプトに指定
init.sh
各種設定ファイル内の
パラメータを環境変数から設定
FIP : Etherpad-LiteのIPアドレス
DB_PORT_3306_TCP_ADDR : MySQLのIPアドレス