Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

Dockerfile-python 2.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  1. # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
  2. # Builds ultralytics/ultralytics:latest-python image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
  3. # Lightweight CPU image optimized for YOLO inference
  4. # Use official Python base image for reproducibility (3.11.10 for export and 3.12.10 for inference)
  5. FROM python:3.11.10-slim-bookworm
  6. # Set environment variables
  7. ENV PYTHONUNBUFFERED=1 \
  8. PYTHONDONTWRITEBYTECODE=1 \
  9. PIP_NO_CACHE_DIR=1 \
  10. PIP_BREAK_SYSTEM_PACKAGES=1
  11. # Downloads to user config dir
  12. ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
  13. https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
  14. /root/.config/Ultralytics/
  15. # Install linux packages
  16. RUN apt-get update && \
  17. apt-get install -y --no-install-recommends \
  18. python3-pip git zip unzip wget curl htop libgl1 libglib2.0-0 && \
  19. apt-get clean && \
  20. rm -rf /var/lib/apt/lists/*
  21. # Create working directory
  22. WORKDIR /ultralytics
  23. # Copy contents and configure git
  24. COPY . .
  25. RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config && \
  26. sed -i'' -e 's/"opencv-python/"opencv-python-headless/' pyproject.toml
  27. ADD https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt .
  28. # Install pip packages
  29. RUN pip install uv && \
  30. uv pip install --system -e . --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match && \
  31. # Remove extra build files
  32. rm -rf tmp ~/.cache /root/.config/Ultralytics/persistent_cache.json
  33. # Usage Examples -------------------------------------------------------------------------------------------------------
  34. # Build and Push
  35. # t=ultralytics/ultralytics:latest-python && sudo docker build -f docker/Dockerfile-python -t $t . && sudo docker push $t
  36. # Run
  37. # t=ultralytics/ultralytics:latest-python && sudo docker run -it --ipc=host $t
  38. # Pull and Run
  39. # t=ultralytics/ultralytics:latest-python && sudo docker pull $t && sudo docker run -it --ipc=host $t
  40. # Pull and Run with local volume mounted
  41. # t=ultralytics/ultralytics:latest-python && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/shared/datasets:/datasets $t
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...