Docker deploy_container sends literal None command when command is omitted
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Bắt đầu tại DockerContainerDriver.deploy_container() trong libcloud/container/drivers/docker.py, nơi command = shlex.split(str(command)) chạy trước khi payload tạo được dựng. Chạy tập lệnh tái hiện trong issue để xác nhận Cmd là ['None'] khi đối số bị bỏ qua. Hoàn tất khi bỏ qua command hoặc truyền None khiến Cmd không có trong yêu cầu, còn các chuỗi được chỉ định rõ như 'echo "hello world"' vẫn được tách thành các đối số.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 2.1k
- Fork
- 935
- Merge trung bình
- 5 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 15
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/libcloud
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Local range download leaves an output file after source-read failure despite delete_on_failure=TrueĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
apache/libcloud#2215 · 3 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/libcloud
Issue tương tự
-
Email validation accepts a trailing newlineCó thể đã có người làm @marcello-pichini đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Contributing instructionsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
dbt-labs/spark-utils#51 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
vendrabuck/HERD#1419 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày