Docker deploy_container sends literal None command when command is omitted
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start in DockerContainerDriver.deploy_container() in libcloud/container/drivers/docker.py, where command = shlex.split(str(command)) runs before the create payload is built. Run the reproduction script in the issue to confirm Cmd is ['None'] when the argument is omitted. Done when omitting command or passing None leaves Cmd out of the request, and explicit strings such as 'echo "hello world"' still split into arguments.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 2.1k
- Forks
- 935
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 15
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/libcloud
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Local range download leaves an output file after source-read failure despite delete_on_failure=TrueOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
apache/libcloud#2215 · 3 comments · 2 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
Maintainers usually reply within 1 day
Similar issues
-
Email validation accepts a trailing newlinePossibly taken @marcello-pichini claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dbt-labs/spark-utils#51 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug frontend
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
vendrabuck/HERD#1419 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day