Skip to content

Commit 643127d

Browse files
committed
chore(deps): update docker-java to 3.6.0 and improve Docker connection handling
- Update docker-java from 3.3.3 to 3.6.0 - Use docker-java default configuration in DockerClientConfigUtil - Add exception handling for container removal and stop operations (404/304 errors) - Add debug logging for Docker connection information
1 parent a46722a commit 643127d

File tree

5 files changed

+76
-4
lines changed

5 files changed

+76
-4
lines changed

.claude/commands/git-commit.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
allowed-tools: Bash(git:*), Bash(npm:*), Read(*.md), Fetch(*)
3+
description: "ワーキングディレクトリでの変更をコミットします"
4+
---
5+
6+
意味のある変更単位ごとにコミットを行うことは、コードの履歴を明確にし、将来の変更を追跡しやすくするために重要です。
7+
8+
以下の手順に従って、ワーキングディレクトリでの変更をコミットします。
9+
10+
### 1. 変更を確認する
11+
12+
まず、現在のワーキングディレクトリでの変更を確認します。以下のコマンドを実行してください:
13+
14+
```bash
15+
git status
16+
```
17+
18+
### 2. 変更をステージングする
19+
20+
変更をコミットする前に、ステージングエリアに追加する必要があります。以下のコマンドを使用して、すべての変更をステージングします:
21+
22+
```bash
23+
git add 対象ファイルやディレクトリ
24+
```
25+
26+
意味のある変更単位ごとにファイルを指定すること。無条件にすべての変更を追加しないでください。
27+
28+
### 3. コミットメッセージを作成する
29+
30+
コミットメッセージは、変更内容を簡潔に説明する重要な部分です。以下のコマンドを使用して、コミットを作成します:
31+
32+
```bash
33+
git commit -m "コミットメッセージをここに入力"
34+
```
35+
36+
コミットメッセージは日本語で記述してください。co-authorやコミットメッセージに"Claude Code"のキーワードは含めないこと。
37+
38+
### 4. コミットを確認する
39+
コミットが正しく行われたかを確認するために、以下のコマンドを実行します:
40+
41+
```bash
42+
git log --oneline
43+
```
44+
45+
これにより、最近のコミットの一覧が表示され、コミットメッセージとハッシュが確認できます。

docker-controller-scala-core/src/main/scala/com/github/j5ik2o/dockerController/DockerClientConfigUtil.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ object DockerClientConfigUtil {
3333
s"Failed to load `docker-machine env $profileName`, so it was fallback to the default configuration.",
3434
ex
3535
)
36+
// Let docker-java handle the default configuration
3637
configBuilder.build()
3738
}
38-
} else
39+
} else {
40+
// Let docker-java handle the default configuration
41+
logger.debug("Using docker-java default configuration")
3942
configBuilder.build()
43+
}
4044
}
4145
}

docker-controller-scala-core/src/main/scala/com/github/j5ik2o/dockerController/DockerController.scala

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,16 @@ private[dockerController] class DockerControllerImpl(
180180
logger.debug("removeContainer --- start")
181181
val configureFunction: RemoveContainerCmd => RemoveContainerCmd =
182182
cmdConfigures.map(_.removeContainerCmdConfigure).getOrElse(identity)
183-
f(configureFunction(newRemoveContainerCmd())).exec()
183+
try {
184+
f(configureFunction(newRemoveContainerCmd())).exec()
185+
} catch {
186+
case e: com.github.dockerjava.api.exception.NotFoundException =>
187+
logger.debug("Container not found (NotFoundException: Status 404)")
188+
case e: com.github.dockerjava.api.exception.NotModifiedException =>
189+
logger.debug("Container already removed (NotModifiedException: Status 304)")
190+
case e: Throwable =>
191+
throw e
192+
}
184193
_containerId = None
185194
logger.debug("removeContainer --- finish")
186195
}
@@ -196,6 +205,7 @@ private[dockerController] class DockerControllerImpl(
196205

197206
override def listImages(f: ListImagesCmd => ListImagesCmd): Vector[Image] = {
198207
logger.debug("listImages --- start")
208+
logger.debug(s"dockerClient: $dockerClient")
199209
val configureFunction: ListImagesCmd => ListImagesCmd =
200210
cmdConfigures.map(_.listImageCmdConfigure).getOrElse(identity)
201211
val result = f(configureFunction(newListImagesCmd())).exec().asScala.toVector
@@ -267,7 +277,14 @@ private[dockerController] class DockerControllerImpl(
267277
logger.debug("stopContainer --- start")
268278
val configureFunction: StopContainerCmd => StopContainerCmd =
269279
cmdConfigures.map(_.stopContainerCmdConfigure).getOrElse(identity)
270-
f(configureFunction(newStopContainerCmd())).exec()
280+
try {
281+
f(configureFunction(newStopContainerCmd())).exec()
282+
} catch {
283+
case e: com.github.dockerjava.api.exception.NotModifiedException =>
284+
logger.debug("Container is already stopped (NotModifiedException: Status 304)")
285+
case e: Throwable =>
286+
throw e
287+
}
271288
logger.debug("stopContainer --- finish")
272289
}
273290

docker-controller-scala-core/src/main/scala/com/github/j5ik2o/dockerController/DockerControllerHelper.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ trait DockerControllerHelper {
1919

2020
protected val dockerHost: String = DockerClientConfigUtil.dockerHost(dockerClientConfig)
2121

22+
logger.debug(s"DockerControllerHelper: Using Docker host: ${dockerClientConfig.getDockerHost}")
23+
logger.debug(s"DockerControllerHelper: Docker host URI: ${dockerClientConfig.getDockerHost.toString}")
24+
logger.debug(s"DockerControllerHelper: Docker host scheme: ${dockerClientConfig.getDockerHost.getScheme}")
25+
logger.debug(s"DockerControllerHelper: Docker host host: ${dockerClientConfig.getDockerHost.getHost}")
26+
logger.debug(s"DockerControllerHelper: Docker host port: ${dockerClientConfig.getDockerHost.getPort}")
27+
2228
protected val dockerHttpClient: DockerHttpClient = new ApacheDockerHttpClient.Builder()
2329
.dockerHost(dockerClientConfig.getDockerHost)
2430
.sslConfig(dockerClientConfig.getSSLConfig)

project/Dependencies.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Dependencies {
99
val scalaTestVersion = "3.2.16"
1010
val logbackVersion = "1.2.12"
1111
val scalaCollectionCompatVersion = "2.11.0"
12-
val dockerJavaVersion = "3.3.3"
12+
val dockerJavaVersion = "3.6.0"
1313
val progressBarVersion = "0.9.5"
1414
val enumeratumVersion = "1.6.1"
1515
}

0 commit comments

Comments
 (0)