Example Dockerfile should document to run python unbuffered
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 50/100
- Type d'issue
- Documentation
- Clarté
- Clairement spécifiée
- Activité
- À l'abandon
- Stack technique
- dockerfile, python
- Domaine
- documentation
Piste de recherche
Commencez par l’exemple de content.md sous « Create a Dockerfile in your python App Project », puis consultez le Docker Python Guide à l’adresse docs.docker.com/language/python/build-images/. Mettez à jour les deux emplacements de la documentation afin d’expliquer la sortie Python non mise en mémoire tampon pour les journaux des conteneurs, d’inclure l’exemple choisi et de vous assurer que les instructions correspondent au comportement de Python cité.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
The example Dockerfile in the Create a Dockerfile in your python App Project section in the image documentation should have
ENV PYTHONUNBUFFERED=1
or add the -u option to
CMD [ "python", "-u", "./your-daemon-or-script.py" ]
From https://docs.python.org/3/library/sys.html#sys.stdout:
When interactive, the
stdoutstream is line-buffered. Otherwise, it is block-buffered like regular text files. Thestderrstream is line-buffered in both cases. You can make both streams unbuffered by passing the-ucommand-line option or setting thePYTHONUNBUFFEREDenvironment variable.
Changed in version 3.9: Non-interactive stderr is now line-buffered instead of fully buffered.
When running a container non-interactively, no output from the python script or daemon are flushed to stdout until the block buffer is full (generally DEFAULT_BUFFER_SIZE = 8192) or the container terminates. For daemons which do not terminate and which may not have much logging over its lifetime, nothing may be logged at all.
This makes viewing / tailing the container logs in realtime which by default captures stdout problematic, especially when viewing the logs in conjunction with other services.
Example docker-compose.yaml which demonstrates this issue.
---
services:
demo:
image: python:3
command:
- python
- -c
- |
import time
for i in range(10):
print(i)
time.sleep(1)
No output is written until the container terminates.
It took me a while to figure out what the problem was, believing it was a problem with Docker not flushing logs to the driver (with --log-opt mode=non-blocking) or getting blocked (with --log-opt mode=blocking - the default), until I realised it was a problem specific to Python. Adding changes to the Python image documentation would help users with similar problems. E.g. https://github.com/moby/moby/issues/12447#issuecomment-94416623 and https://stackoverflow.com/questions/29663459/python-app-does-not-print-anything-when-running-detached-in-docker
The Docker Python Guide docs, https://docs.docker.com/language/python/build-images/ should also be updated.
- Langage dominant
- Dockerfile
- Étoiles
- 2.8k
- Forks
- 1.1k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de docker-library/python
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
docker-library/python#1151 ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 38/100
docker-library/python#1150 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 54/100
docker-library/python#1147 ·
-
Provide 3.13t & 3.14t imagesOuverte
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
docker-library/python#1082 · 10 commentaires · 40 réactions ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
docker-library/python#1076 · 5 commentaires · 1 réaction ·
Toutes les issues de docker-library/python
Issues similaires
-
good first issue
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 1 jour
-
[ordering-review] workshop order graph: 1 confirmed ordering issue, cycles are false positivesOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
githubnext/gh-aw-workshop#6247 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
brucemiller/LaTeXML#2894 ·
-
CONTRIBUTING.md and the release checklist still describe tag-based versioning and a `develop` branchOuvertedocs
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
developmentseed/titiler-cmr#355 ·
Les mainteneurs répondent en général sous 1 jour