# LXD/LXC Открытие портов

## Подготовка и использование

## Открытие определённого порта для контейнера

самый лёгкий способ открыть порт для контейнера и это при использовании **прокси девайса (proxy device)**.

Приведём пример, и на нём рассмотрим какая часть команды что делает

{% hint style="info" %}
&#x20;Команда прописывается после создания контейнера.
{% endhint %}

```
lxc config device add container pdevice09093 proxy listen=tcp:0.0.0.0:09093 connect=tcp:127.0.0.1:09093
```

Команда создаёт прокси девайс который открывает определенный порт.

1. `lxc config device add`, добавляет девайс
2. `container`, в наш созданный контейнер,
3. `myport80`, с именем **pdevice09093**,
4. `proxy`, который считается как **LXD прокси девайс**.
5. `listen=tcp:0.0.0.0:80`, мы **слушаем** (Дефолтно прописанный на хосет) на порт **09093**
6. `connect=tcp:127.0.0.1:80`, мы соеденяемся (к нашему контейнеру) к существующему порту 09093 TCP на локалхосте, которым является `sshd`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.ted.ge/lxd-lxc-otkrytie-portov.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
