0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

springbootアプリをDockerコンテナにデプロイするサンプル

Posted at

ローカルコンテナ環境に、springbootアプリをデプロイします。

まずは、環境の説明から始めましょう。

OS=Ubuntu 24
Java=25
maven=3.8.7
docker=28.4

プロジェクトルートフォルダに移動します。

$ cd ~/java/app1

パッケージを作ります。

$ mvn clean package spring-boot:repackage

コンテナイメージを作ります。

$ docker build -t app1:latest .

コンテナを起動して動作確認します。

デフォルトのポート番号:8080を 80番ポートに変換します。

$ docker run -p 80:8080 app1:latest

ブラウザで動作確認します。

http://localhost/

Hello, World! Sun Sep 28 12:25:03 UTC 2025と表示されれば、OKです。
(タイムスタンプは随時変わります)

docker のイメージを見てみます。

$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
app1         latest    d1b7804478fc   9 minutes ago   506MB

以上

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?