Управление Docker контейнерами с помощью docker-py
docker-py – это официальная библиотека Python для Docker, предоставляющая API для взаимодействия с Docker Daemon. С её помощью можно автоматизировать процессы создания, запуска, остановки и удаления контейнеров, работы с образами, сетями и томами Docker.
import docker
# Создание клиента
client = docker.from_env()
# Запуск контейнера
container = client.containers.run("ubuntu:latest", "echo Hello, docker-py!", detach=True)
# Получение логов контейнера
print(container.logs().decode())
# Остановка и удаление контейнера
container.stop()
container.remove()
В данном примере мы создаем клиента Docker, используя переменные окружения текущей сессии. Затем мы запускаем контейнер из образа ubuntu:latest, выполняем в нем команду echo, выводим логи работы контейнера и в конце останавливаем и удаляем контейнер.
Управление образами с помощью docker-py:
# Получение списка всех образов
images = client.images.list()
# Вывод информации о каждом образе
for image in images:
print(f'ID: {image.id}, Теги: {image.tags}')
Для дальнейшего изучения и ознакомления с более продвинутыми возможностями рекомендуется обратиться к официальной документации.
#python#docker#dockerpy
http://www.bogotobogo.com/python/python_unit_testing.php
#python#unit_test
In this chapter, we're going to write and debug a set of functions to convert to and from Hexa numbers.
We can start mapping out what a hexa.py module should do. It will have two main functions, toHexa() and fromHexa(). The toHexa() function should take an integer from 1 to 65536 and return the hexa numeral representation as a string.
#python#databases
🐍
Advanced Python: Working with multiple databases
Description
Build and connect Python Application to multiple databases
🔗Link
-----
Main channel: @repo_science
Coupons: @freecoupons_reposcience
-----
#python#databases
🐍
Advanced Python: Practical Database Examples
Level up as a Python developer working with databases in this advanced, skills-based course.
🔗Link
-----
Main channel:@repo_science
Coupons: @freecoupons_reposcience
-----
#python#ai#ocr
Chandra OCR 2 is a top OCR model that turns images and PDFs into structured Markdown, HTML, or JSON, keeping layout, tables, math, handwriting, and 90+ languages accurate—it leads benchmarks like olmOCR (85.9% overall) and multilingual tests (77.8% average). Install easily with `pip install chandra-ocr` for CLI use, local HuggingFace, or fast vLLM server; try the free playground first. You benefit by quickly digitizing complex docs with high precision, saving time on extraction and enabling easy editing or analysis without manual fixes.
https://github.com/datalab-to/chandra