Docker deploy_container sends literal None command when command is omitted
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
Direzione di ricerca
Inizia in DockerContainerDriver.deploy_container() in libcloud/container/drivers/docker.py, dove command = shlex.split(str(command)) viene eseguito prima di creare il payload di creazione. Esegui lo script di riproduzione nell’issue per confermare che Cmd è ['None'] quando l’argomento viene omesso. Il lavoro sarà completato quando omettere command o passare None lascerà Cmd fuori dalla richiesta e le stringhe esplicite come 'echo "hello world"' continueranno a essere suddivise in argomenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 2.1k
- Fork
- 935
- Merge medio
- 5g 3h
- PR unite (30g)
- 15
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/libcloud
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Local range download leaves an output file after source-read failure despite delete_on_failure=TrueAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
apache/libcloud#2215 · 3 commenti · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/libcloud
Issue simili
-
Email validation accepts a trailing newlineForse già presa @marcello-pichini l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Contributing instructionsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
dbt-labs/spark-utils#51 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
bug frontend
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
vendrabuck/HERD#1419 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno