dockerインストール
yum install docker
dockerサービス起動
service docker start
新規立ち上げたインスタンスなので、足りないコマンドのインストールが必要になる
yum install passwd initscripts vim -y
passwd
yum install openssh openssh-clients openssh-server -y
vi /etc/ssh/sshd_config
UsePAM yes
→UsePAM no # noに変更
#PermitRootLogin yes
→PermitRootLogin yes
service sshd start
Generating SSH2 RSA host key: [ OK ]
Generating SSH1 RSA host key: [ OK ]
Generating SSH2 DSA host key: [ OK ]
Starting sshd: [ OK ]
yum install httpd git make bzip2 -y
PHPを利用しているので、環境切り替えのため、phpenvのインストール
mkdir -p repos/git
cd repos/git
git clone https://github.com/CHH/phpenv.git
cd phpenv/bin
./phpenv-install.sh
Installing phpenv in /path/to/.phpenv
remote: Counting objects: 1889, done.
remote: Total 1889 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (1889/1889), 297.15 KiB | 155 KiB/s, done.
Resolving deltas: 100% (1182/1182), done.
Success.
export PATH="/path/to/.phpenv/bin:$PATH"
eval "$(phpenv init -)"
Add above line at the end of your ~/.bashrc and restart your shell to use phpenv.
$ source ~/.bashrc
php-buildインストール
git clone https://github.com/php-build/php-build $HOME/.phpenv/plugins/php-build
apxsインストール
yum install httpd-devel -y
which apxs
PHPコンパイルオプション設定
find / -name default_configure_options
vi /root/.phpenv/plugins/php-build/share/php-build/default_configure_options
--with-apxs2=/usr/bin/apxs
--with-tidy
必要なコマンドインストール
yum install php-pear php-devel re2c file autoconf mysql-devel -y
PHP7インストール
phpenv install 7.0.10
旧バージョンPHPアンインストール
yum remove php-cli.x86_64
環境変数設定
which php
/root/.phpenv/shims/php
vi ~/.bashrc
export PATH="/root/.phpenv/bin:$PATH"
export PATH="/root/.phpenv/shims:$PATH"
eval "$(phpenv init -)"
source ~/.bashrc
PHPバージョン設定
phpenv local 7.0.10
phpenv global 7.0.10
php -v
MYSQL5.6インストール
yum -y install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum -y install mysql-community-server
mysqld --version
chkconfig mysqld on
初期設定
mysql_secure_installation
コンテナ一覧(停止コンテナ含む、サイズ表示)
docker ps -a
コミット
docker commit コンテナID DockerHub上リポジトリ名
例:
docker commit 123456789098 test/docker-test
DockerHubに反映(Push)
docker login
docker push test/docker-test:latest
DockerHubの「Organizations & Teams」に反映
docker pull teamabc/test
teamabc/testはOrganizationsにあるリポジトリ名
docker commit 123456789098 teamabc/test
docker push teamabc/test:latest
コンテナ起動コマンドのメモ
docker run --privileged --name teamabc -d teamabc/test /sbin/init
docker exec -ti teamabc bash
docker run -p 88:80 --name teamabc -d teamabc/test
docker exec -ti teamabc bash
WARNING: terminal is not fully functional回避
docker exec -ti teamabc env TERM=xterm bash