MYCSS

Показ дописів із міткою docker. Показати всі дописи
Показ дописів із міткою docker. Показати всі дописи

2026-01-30

Windows Docker. Virtual image file just only grow size of .vhds file.

Куди зникає місце на диску?

Docker у Windows працює через WSL (Windows Subsystem for Linux), яка в свою чергу використовує віртуалізацію Hyper‑V. Це означає, що всі дані зберігаються у файлах образів віртуальних дисків .vhdx.

З часом диск починає стрімко розростатися, і рано чи пізно місце на системному SSD закінчується. Тоді виникає питання: куди ж воно поділося?

На допомогу приходить утиліта WinTree (diskanalyzer.com), яка дозволяє швидко побачити, що саме займає простір.

Саме так я й з’ясував, що проблема була у Docker. Але коли перевірив сам Docker - там усе вже очищено, а файл .vhdx продовжував залишатися гігантським.

docker system df

TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          2         2         329.2MB   0B (0%)
Containers      3         0         2B        2B (100%)
Local Volumes   62        1         2.309GB   2.125GB (92%)
Build Cache     0         0         0B

Чому VHDX росте безконтрольно.

Реальний розмір віртуального тому завжди більший за фактичні дані. Це відбувається тому, що .vhdx‑файл у WSL та Docker може лише збільшуватися у міру потреби. 

Коли ти видаляєш образи чи очищаєш дані, простір всередині Linux‑файлової системи звільняється, але сам файл на диску не стискається автоматично. 

Тому він продовжує залишатися гігантським, навіть якщо даних там майже немає. 

Docker .vhdx before compact

Стискаємо образ диску 

Виходимо з застосунку "Docker Desktop" та робимо завершення "WSL":
wsl --shutdown
Стискаємо VHD файл відкриваючи консоль PowerShell як Administrator.
Optimize-VHD -Path "$env:LOCALAPPDATA\Docker\wsl\disk\docker_data.vhdx" -Mode Full

Тепер набагато краще.

Docker .vhdx after compact

 

2025-06-21

Docker Port Is Busy on Windows? Fix for: bind: An attempt was made to access a socket in a way forbidden by its access permission.

If you're getting a Docker error like:

(HTTP code 500) server error - ports are not available: exposing port TCP 0.0.0.0:8182 -> 127.0.0.1:0: listen tcp 0.0.0.0:8182: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
But nothing is using the port, it’s likely because Windows has excluded the port dynamically, especially after Docker was previously using it. 
 
(HTTP code 500) server error - ports are not available

1. Verify Nothing Is Listening on the Port

netstat -aon | findstr :8181

If you see no output, the port is not in use by any application.

2. Check Excluded Port Ranges:

netsh interface ipv4 show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges

Start Port    End Port
----------    --------
      6575        6674
      7162        7261
      7262        7361
      7362        7461
      7462        7561
      7562        7661
      7681        7780
      7781        7880
      7881        7980
      7981        8080
      8081        8180
      8181        8280
      8281        8380
      8381        8480
      8481        8580
     30604       30703
     49690       49789
     49790       49889
     49890       49989
     50000       50059     *
     50160       50259
     50360       50459
     50460       50559
     50660       50759
     50760       50859
     50860       50959
     51064       51163
     51243       51342
     51344       51443

You’ll notice 8182 falls within the 8181–8280 range - without a * at the end, meaning it's a dynamically excluded port.

You cannot remove dynamic exclusions manually.

3. Restart winnat Service to Clear Dynamic Exclusions: 

This step clears dynamic port reservations created by services like Docker: 
net stop winnat
net start winnat

* Run the above in Administrator Command Prompt 

 

4. Recheck Excluded Ports:

netsh int ipv4 show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges

Start Port    End Port
----------    --------
     50000       50059     *

* - Administered port exclusions.

If 8182 is no longer in the list, you're good to go.

2025-03-23

🚀 Docker-Compose Generator for ElasticSearch Cluster

Are you tired of manually configuring docker-compose.yml files for Elasticsearch clusters? Say hello to this easy-to-use Python script that automates the process! 🐍

📌 What it does:

This script generates a docker-compose.yml file for setting up an ElasticSearch cluster using template files and environment variables. It creates a cluster with Docker containers, including:

  • ElasticSearch nodes with different roles (master, data, ingest, coordinator)
  • Kibana for visualization
  • Additional service containers

🔧 How it works:

  • Configure your cluster setup using a .env file.
  • Run the script, and voilà! Your docker-compose.yml is ready.

📶 Test Environment:

The generated cluster was tested on a TrueNAS SCALE 24.10.2 server, deployed as a custom application by importing the YAML file. Storage was configured using ZFS Datasets, ensuring reliability and scalability.

💡 Why it’s awesome:

  • Saves time and reduces errors in manual configuration.
  • Flexible and customizable for different cluster setups.
  • Perfect for DevOps engineers and developers working with ElasticSearch.

🔗 Script: https://github.com/lexxai/es_cluster_docker_helper
🔗 Prototype: https://github.com/evermight/elastic-cluster-docker-compose

2024-10-19

FastAPI Dependency Injection: 21 Examples Using Depends() with AI Answers

Why ?

Once I wanted to understand how Depends works in FastAPI more thoroughly to understand what's under the hood. I started communicating with the AI. The answer was a question, and I got hooked. 
I decided to test it in real code and created a training project and wrote this post for it based on my questions to the AI and its answers.
Some answers were wrong, some I had already optimized a bit. But all the results shown are real and created by me personally. 
The result was 21 training examples written in Python, where I checked the answers and suggestions from the AI.

 

2024-05-01

Certificate from IT academy GoIT - Python developer

Минув рік дуже інтенсивного навчання в IT академії GoIT - тепер я Python Developer.

Моїм напрямком було вивчення мови програмування #Python з застосуванням у вебзастосунках та у галузі Data Science і машинного навчання (ML).

 Отримав сертифікат Python Developer.

Сертифікат Python Developer.

 

Коли забув ти рідну мову, біднієш духом ти щодня...
When you forgot your native language you would become a poor at spirit every day ...

Д.Білоус / D.Bilous
Рабів до раю не пускають. Будь вільним!

ipv6 ready