Docker deploy_container sends literal None command when command is omitted
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
調査の方向性
libcloud/container/drivers/docker.py の DockerContainerDriver.deploy_container() から始めます。ここでは、create payload が構築される前に command = shlex.split(str(command)) が実行されます。issue の再現スクリプトを実行し、引数を省略したときに Cmd が ['None'] になることを確認します。command を省略するか None を渡したときに Cmd がリクエストから除外され、'echo "hello world"' のような明示的な文字列は引き続き引数に分割される状態になれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
DockerContainerDriver.deploy_container() turns its default command=None into the literal command ['None'] in the container-create request. Omitting the argument therefore sends an explicit command override rather than leaving the image's default command alone.
The documented Docker example calls deploy_container('tomcat', image) without a command.
Detailed Information
Observed on unchanged trunk 8a0ef6260680625d54fce5093d2315e0926a7dc9, Libcloud 4.0.0.dev0, Python 3.12/Linux. This is a request-serialization reproduction using the actual driver method with API-version negotiation and response transport substituted. No Docker daemon/container was started.
import json
from types import SimpleNamespace
from unittest.mock import patch
from libcloud.container.drivers.docker import DockerContainerDriver
from libcloud.container.base import ContainerImage
with patch.object(DockerContainerDriver, '_get_api_version', return_value='1.24'):
driver = DockerContainerDriver()
image = ContainerImage('i', 'test-image', 'test-image', 'latest', driver)
for kwargs in ({}, {'command': None}, {'command': ''},
{'command': 'echo "hello world"'}):
requests = []
def request(action, **options):
requests.append((action, options))
body = {'Id': 'local-probe'} if action.endswith('/create') else {
'Id': 'local-probe', 'Name': '/local-probe',
'Image': 'test-image', 'Status': 'Created', 'Ports': []}
return SimpleNamespace(object=body)
driver.connection = SimpleNamespace(request=request, driver=driver)
driver.deploy_container('local-probe', image, start=False, **kwargs)
print(kwargs, json.loads(requests[0][1]['data'])['Cmd'])
Output:
{} ['None']
{'command': None} ['None']
{'command': ''} []
{'command': 'echo "hello world"'} ['echo', 'hello world']
The cause is command = shlex.split(str(command)) before building the payload. The optional absent value is converted to text before splitting. Expected: preserve the no-command-override case while retaining parsing of explicit command strings.
Docker's CMD documentation describes the image command as a default, overridden by supplied command arguments. This report establishes the incorrect outgoing Cmd, not a live-daemon startup error or full-suite result. No production code change yet.
AI assistance: ChatGPT helped investigate, reproduce, and draft this report.
- 主要言語
- Python
- スター
- 2.1k
- フォーク
- 935
- 平均マージ
- 5日 3時間
- マージ済み PR(30日)
- 15
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/libcloud のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
Local range download leaves an output file after source-read failure despite delete_on_failure=Trueオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
apache/libcloud#2215 · コメント 3 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
メンテナーはふだん 1 日以内に返信
apache/libcloud の issue をすべて見る
似ている issue
-
Email validation accepts a trailing newline対応中かも @marcello-pichini が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
dbt-labs/spark-utils#51 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
bug frontend
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
vendrabuck/HERD#1419 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信