環境セットアップ
2025/08/29約2分インストールとデプロイ
バージョン要件
| コンポーネント | バージョン要件 |
|---|---|
| JDK | 1.8 |
| Docker | 24.0.7+ |
| Docker Compose | 2.20.2+ |
1. JDK 1.8
1.1 JDK をダウンロード
https://www.oracle.com/java/technologies/javase/javase8-archive-downloads.htmljdk-8u401-linux-x64.tar.gz をダウンロードし、サーバーへアップロードします。
1.2 デプロイディレクトリへ展開
sudo mkdir -p /opt/java
sudo tar zxvf jdk-8u201-linux-x64.tar.gz -C /opt/java/
sudo mv /opt/java/jdk1.8.0_201 /opt/java/openjdk1.3 環境変数を設定
/etc/profile を開き、ファイル末尾に次の内容を加えるします。
export JAVA_HOME=/opt/java/openjdk
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=.${JAVA_HOME}/bin:$PATH1.4 現在の bash 環境で /etc/profile のコマンドを読み込んで実行
source /etc/profile1.5 デプロイ成功を確認
java -version2. Docker
2.1 Docker オフラインパッケージをダウンロード
https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgzdocker-24.0.7.tgz をダウンロードし、サーバーへアップロードします。
2.2 docker.service ファイルを作る
sudo vi docker.service次の内容を入力し、ファイルを保存します。
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target2.3 install.sh ファイルを作る
sudo vi install.sh次の内容を入力し、ファイルを保存します。
#!/bin/sh
echo 'tar パッケージを展開中...'
tar -xvf $1
echo 'docker ディレクトリを /usr/bin へ移動中...'
cp docker/* /usr/bin/
echo 'docker.service を /etc/systemd/system/ へ移動中...'
cp docker.service /etc/systemd/system/
echo 'ファイル権限を加える中...'
chmod +x /etc/systemd/system/docker.service
echo '設定ファイルを再読み込み中...'
systemctl daemon-reload
echo 'docker を起動中...'
systemctl start docker
echo '起動時の自動開始を有効化中...'
systemctl enable docker.service
echo 'Docker のインストールに成功しました...'
docker -v2.4 docker を起動
chmod +x install.sh
./install.sh docker-24.0.7.tgz2.5 デプロイ成功を確認
sudo docker -v
# 通常出力: Docker version 24.0.7, build afdd53b3. Docker Compose
3.1 Docker Compose オフラインパッケージをダウンロード
https://github.com/docker/compose/releases/download/v2.20.2/docker-compose-linux-x86_64docker-compose-linux-x86_64 をダウンロードし、サーバーへアップロードします。
3.2 デプロイ
sudo mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose3.3 デプロイ成功を確認
sudo docker-compose -v
# 通常出力: Docker Compose version v2.20.2