JunaidAhamed-7777 opened a new issue, #2226: URL: https://github.com/apache/libcloud/issues/2226
## 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](https://github.com/apache/libcloud/blob/8a0ef6260680625d54fce5093d2315e0926a7dc9/docs/examples/container/docker/deploy_container.py) 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. ```python 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: ```text {} ['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](https://docs.docker.com/reference/dockerfile/#cmd) 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. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
