jpskill.com
🛠️ 開発・MCP コミュニティ

routeros-container

RouterOS /container subsystem for running OCI containers on MikroTik devices. Use when: enabling containers on RouterOS, setting up VETH/bridge networking for containers, managing container lifecycle via CLI or REST API, building OCI images for RouterOS, configuring container environment variables, troubleshooting container issues, or when the user mentions RouterOS container, /container, VETH, device-mode container, or MikroTik Docker.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o routeros-container.zip https://jpskill.com/download/20951.zip && unzip -o routeros-container.zip && rm routeros-container.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/20951.zip -OutFile "$d\routeros-container.zip"; Expand-Archive "$d\routeros-container.zip" -DestinationPath $d -Force; ri "$d\routeros-container.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して routeros-container.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → routeros-container フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

RouterOS コンテナサブシステム

概要

RouterOS 7.x には、OCI 互換のコンテナイメージを MikroTik ハードウェア上で直接実行するコンテナサブシステム (/container) が含まれています。これは Docker ではありません。MikroTik 独自の、大幅な違いを持つ実装です。

要件:

  • container 追加パッケージがインストールされた RouterOS 7.x
  • デバイスモードが有効になっていること(初期設定には物理的なアクセスが必要です)
  • 十分なストレージ(外部 USB ディスクを推奨、100+ MB/s、10K+ ランダム IOPS)
  • ARM、ARM64、または x86 アーキテクチャ(MIPS はコンテナでサポートされていません)

デバイスモード — 物理的なアクセスが必要です

コンテナのサポートはデバイスモードによって制限されており、有効にするには物理的な確認(リセットボタンを押すか、電源を入れ直す)が必要です。

# コンテナモードを有効にする
/system/device-mode/update mode=advanced container=yes

# 実行後、activation-timeout 内に物理的に確認してください
# - リセットボタンを押す、または
# - デバイスの電源を入れ直す

デバイスモードは、コンテナ固有のものではなく、一般的な RouterOS のセキュリティ機能です。これは、4つのモード(homebasicadvancedrose)にわたる多くの機能(スケジューラ、フェッチ、スニッファなど)を制限し、デバイスに依存する工場出荷時のデフォルト設定があります。

完全な機能マトリックス、モード、更新プロパティ、および物理的な確認の詳細については、routeros-fundamentals スキルのデバイスモードリファレンスを参照してください。

モードスクリプトによるバイパス (7.22+): netinstall 中に、モードスクリプト (-sm) を使用して初回起動時にデバイスモードを設定し、自動的に再起動をトリガーできます。routeros-netinstall スキルを参照してください。

コンテナパッケージのインストール

# コンテナパッケージがすでにインストールされているか確認する
/system/package/print where name=container

方法 1: .npk ファイルをアップロード + apply-changes (オフライン)

# SCP 経由でアップロード (または Winbox のドラッグアンドドロップ、WebFig のファイルアップロード)
scp container-7.22-arm64.npk admin@router:/
# 変更を適用する (再起動をトリガーし、アクティベートします — /system/reboot は機能しません!)
/system/package/apply-changes

⚠️ 重要: /system/package/apply-changes は RouterOS 7.18 で追加されました。 7.18 以降では常にこれを使用してください。単なる /system/reboot ではアップロードされたパッケージが破棄されます。7.18 未満のバージョンでは、/system/reboot が正しい(そして唯一の)方法です。(ラボ検証済み: 7.22.1 は apply-changes を使用し、7.10 は reboot を必要とします。rosetta コマンドツリーでバージョンを確認してください。)

方法 2: オンラインパッケージアップデート (インターネット接続が必要です)

/system/package/update check-for-updates
/system/package/update install

これにより、追加パッケージを含む利用可能なすべてのアップデートがダウンロードされ、インストールされます。すでにアップロードされているがアクティブになっていない特定のパッケージを有効にするには、/system/package/enable container を使用し、その後 /system/package/apply-changes を使用します。

ネットワーク設定

VETH (仮想イーサネット)

コンテナは VETH インターフェースを介して RouterOS ネットワークに接続します。

# VETH ペアを作成する
/interface/veth/add name=veth-myapp address=172.17.0.2/24 gateway=172.17.0.1

# VETH 名がコンテナのインターフェース名になります (RouterOS 7.21+)

ブリッジ設定

# コンテナ用のブリッジを作成する
/interface/bridge/add name=containers

# VETH をブリッジに追加する
/interface/bridge/port/add bridge=containers interface=veth-myapp

# ブリッジに IP を割り当てる (コンテナのゲートウェイとして機能します)
/ip/address/add address=172.17.0.1/24 interface=containers

NAT / ファイアウォール

# インターネットアクセス用のコンテナトラフィックをマスカレードする
/ip/firewall/nat/add chain=srcnat action=masquerade src-address=172.17.0.0/24

# ホストからコンテナへのポートフォワーディング
/ip/firewall/nat/add chain=dstnat action=dst-nat \
  dst-port=8080 protocol=tcp to-addresses=172.17.0.2 to-ports=80

# インターフェースリストでコンテナブリッジを許可する (ファイアウォールが制限している場合)
/interface/list/member/add list=LAN interface=containers

レイヤ 2 ネットワーキング (ブリッジモード)

物理インターフェースと同じ L2 ネットワーク上にある必要があるコンテナ(例: netinstall)の場合:

# 物理ポートと VETH の両方を同じブリッジに追加する
/interface/bridge/port/add bridge=mybridge interface=ether5
/interface/bridge/port/add bridge=mybridge interface=veth-netinstall

これにより、コンテナは ether5 上のデバイスに直接 L2 アクセスできるようになります。

環境変数とマウント

コンテナに環境変数とマウントをアタッチする方法は2つあります (7.21+ から):

インライン (7.21+ で推奨)

/container/addenv=mount= を直接設定します。これにより、コンテナが自己完結型になります。

# インライン環境変数とマウント (7.21+)
/container/add remote-image=pihole/pihole:latest interface=veth1 \
  env="TZ=Europe/Riga,WEBPASSWORD=secret" \
  mount="src=disk1/pihole,dst=/etc/pihole" \
  root-dir=disk1/images/pihole logging=yes

これは /app YAML が内部で機能する方法でもあります。インラインは最新のパターンであり、自動化が容易です(管理する個別のリンクされたオブジェクトがありません)。

名前付きリスト (すべてのバージョンで動作)

環境変数とマウントを個別のオブジェクトとして作成し、名前で参照します。

# 名前付き環境変数リストを作成する (7.20+ — 'list=' プロパティが環境変数をグループ化します)
/container/envs/add list=MYAPP key=TZ value="Europe/Riga"
/container/envs/add list=MYAPP key=WEBPASSWORD value="secret"

# 名前付きマウントを作成する
/container/mounts/add name=appdata src=disk1/appdata dst=/data

# コンテナから参照する (7.20+ は 'envlists=' を使用、7.20 未満は 'envlist=' を使用)
/container/add file=myimage.tar interface=veth1 \
  envlists=MYAPP mountlists=appdata root-dir=disk1/myapp

ベストプラクティス: コンテナボリュームは常に外部ディスク (disk1/) に配置し、内部フラッシュストレージには決して配置しないでください。

プロパティ名の履歴

環境変数/マウント参照プロパティの命名は、バージョン境界で変更されました。

バージョン 環境変数リストのグループ化 (/container/envs/add) コンテナ環境変数参照 (/container/add) コンテナマウント参照
7.20 未満 key=, value= のみ (グループ化プロパティなし) (環境変数参照プロパティなし) (利用不可)
7.20 list= が追加 envlists= (複数形) が追加 (利用不可)
7.21+ list= `envlis
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

RouterOS Container Subsystem

Overview

RouterOS 7.x includes a container subsystem (/container) that runs OCI-compatible container images directly on MikroTik hardware. It is NOT Docker — it's MikroTik's own implementation with significant differences.

Requirements:

  • RouterOS 7.x with container extra package installed
  • Device-mode must be enabled (requires physical access for initial setup)
  • Sufficient storage (external USB disk recommended, 100+ MB/s, 10K+ random IOPS)
  • ARM, ARM64, or x86 architecture (MIPS not supported for containers)

Device-Mode — Physical Access Required

Container support is gated behind device-mode, which requires physical confirmation (reset button press or power cycle) to enable:

# Enable container mode
/system/device-mode/update mode=advanced container=yes

# After executing: physically confirm within activation-timeout
# - Press reset button, OR
# - Power cycle the device

Device-mode is a general RouterOS security feature — not container-specific. It gates many features (scheduler, fetch, sniffer, etc.) across four modes (home, basic, advanced, rose) with device-dependent factory defaults.

For the full feature matrix, modes, update properties, and physical confirmation details: see the Device-mode reference in the routeros-fundamentals skill.

Mode script bypass (7.22+): During netinstall, a mode script (-sm) can set device-mode on first boot, automatically triggering a reboot. See the routeros-netinstall skill.

Installing the Container Package

# Check if container package is already installed
/system/package/print where name=container

Method 1: Upload .npk file + apply-changes (offline)

# Upload via SCP (or Winbox drag-and-drop, or WebFig file upload)
scp container-7.22-arm64.npk admin@router:/
# Apply changes (triggers reboot AND activates — /system/reboot does NOT work!)
/system/package/apply-changes

⚠️ Critical: /system/package/apply-changes was added in RouterOS 7.18. On 7.18+, always use it — a plain /system/reboot discards uploaded packages. On versions <7.18, /system/reboot IS the correct (and only) method. (Lab-verified: 7.22.1 uses apply-changes, 7.10 requires reboot. Version check via rosetta command tree.)

Method 2: Online package update (requires internet)

/system/package/update check-for-updates
/system/package/update install

This downloads and installs all available updates including extra packages. To enable a specific package already uploaded but not active, use /system/package/enable container then /system/package/apply-changes.

Networking Setup

VETH (Virtual Ethernet)

Containers connect to RouterOS networking via VETH interfaces:

# Create VETH pair
/interface/veth/add name=veth-myapp address=172.17.0.2/24 gateway=172.17.0.1

# The VETH name IS the container's interface name (RouterOS 7.21+)

Bridge Setup

# Create a bridge for containers
/interface/bridge/add name=containers

# Add VETH to the bridge
/interface/bridge/port/add bridge=containers interface=veth-myapp

# Assign IP to bridge (acts as gateway for containers)
/ip/address/add address=172.17.0.1/24 interface=containers

NAT / Firewall

# Masquerade container traffic for internet access
/ip/firewall/nat/add chain=srcnat action=masquerade src-address=172.17.0.0/24

# Port forwarding from host to container
/ip/firewall/nat/add chain=dstnat action=dst-nat \
  dst-port=8080 protocol=tcp to-addresses=172.17.0.2 to-ports=80

# Allow container bridge in interface list (if firewall restricts)
/interface/list/member/add list=LAN interface=containers

Layer 2 Networking (Bridge Mode)

For containers that need to be on the same L2 network as physical interfaces (e.g., netinstall):

# Add both physical port and VETH to the same bridge
/interface/bridge/port/add bridge=mybridge interface=ether5
/interface/bridge/port/add bridge=mybridge interface=veth-netinstall

This gives the container direct L2 access to devices on ether5.

Environment Variables and Mounts

There are two ways to attach env vars and mounts to a container (from 7.21+):

Inline (preferred for 7.21+)

Set env= and mount= directly on /container/add — keeps the container self-contained:

# Inline env vars and mount (7.21+)
/container/add remote-image=pihole/pihole:latest interface=veth1 \
  env="TZ=Europe/Riga,WEBPASSWORD=secret" \
  mount="src=disk1/pihole,dst=/etc/pihole" \
  root-dir=disk1/images/pihole logging=yes

This is also how /app YAML works under the hood — inline is the modern pattern and easier for automation (no separate linked objects to manage).

Named Lists (works across all versions)

Create env vars and mounts as separate objects, then reference by name:

# Create named env list (7.20+ — the 'list=' property groups envs together)
/container/envs/add list=MYAPP key=TZ value="Europe/Riga"
/container/envs/add list=MYAPP key=WEBPASSWORD value="secret"

# Create named mount
/container/mounts/add name=appdata src=disk1/appdata dst=/data

# Reference from container (7.20+ uses 'envlists=', pre-7.20 used 'envlist=')
/container/add file=myimage.tar interface=veth1 \
  envlists=MYAPP mountlists=appdata root-dir=disk1/myapp

Best practice: Always place container volumes on external disk (disk1/), never on internal flash storage.

Property Name History

The naming of env/mount reference properties changed at version boundaries:

Version Env list grouping (/container/envs/add) Container env reference (/container/add) Container mount reference
Pre-7.20 key=, value= only (no grouping property) (no env reference property) (not available)
7.20 list= added envlists= (plural) added (not available)
7.21+ list= envlists= + inline env= mountlists= + inline mount=

Version note: Property names for 7.20+ are confirmed against /console/inspect command tree data. Pre-7.20, /container/envs/add had only key and value with no grouping mechanism; /container/add had no env reference property. Inline env= and mount= were added at 7.21.

Container Image Formats

RouterOS accepts container images in these formats:

Option A: Pull from Registry

/container/config/set registry-url=https://registry-1.docker.io tmpdir=disk1/pull
/container/add remote-image=library/alpine:latest interface=veth-myapp

Option B: Import Local Tar File

Upload a Docker v1 tar to the router, then:

/container/add file=myimage.tar interface=veth-myapp

OCI Image Requirements for Local Import

RouterOS's container loader has specific requirements for local tar files:

  1. Single layer only — multi-layer images are not supported
  2. No gzip compression — layers must be uncompressed tar
  3. Docker v1 manifest formatmanifest.json + config.json + layer.tar
myimage.tar
├── manifest.json    # [{"Config":"config.json","RepoTags":["name:tag"],"Layers":["layer.tar"]}]
├── config.json      # {"architecture":"arm64","os":"linux","config":{...},"rootfs":{...}}
└── layer.tar        # Uncompressed tar of the full filesystem

These constraints are the key difference from standard OCI images — most base images from public registries already meet requirement 1 and 2 via registry pull; local tar builds must satisfy all three.

Container Lifecycle

CLI

# Create container (7.21+ inline syntax)
/container/add file=myimage.tar interface=veth-myapp \
  env="MY_VAR=hello" mount="src=disk1/appdata,dst=/data" \
  root-dir=disk1/myapp logging=yes

# Start
/container/start [find tag~"myapp"]

# Stop
/container/stop [find tag~"myapp"]

# View status
/container/print

# View logs (if logging=yes)
/log/print where topics~"container"

# Remove (must be fully stopped first)
/container/remove [find tag~"myapp"]

REST API

const base = "http://192.168.1.1/rest";
const auth = { headers: { Authorization: `Basic ${btoa("admin:")}` } };

// List containers
const containers = await fetch(`${base}/container`, auth).then(r => r.json());

// Start container by ID
await fetch(`${base}/container/start`, {
  method: "POST", ...auth,
  headers: { ...auth.headers, "Content-Type": "application/json" },
  body: JSON.stringify({ ".id": "*1" }),
});

// Check status — .running field is "true"/"false" (strings!)
const status = await fetch(`${base}/container/*1`, auth).then(r => r.json());
if (status.running === "true") { /* container is running */ }

// Stop container
await fetch(`${base}/container/stop`, {
  method: "POST", ...auth,
  body: JSON.stringify({ ".id": "*1" }),
});

// Delete — must be fully stopped. Poll .running and retry.
async function deleteContainer(id) {
  for (let i = 0; i < 5; i++) {
    const c = await fetch(`${base}/container/${id}`, auth).then(r => r.json());
    if (c.running === "false") {
      await fetch(`${base}/container/${id}`, { method: "DELETE", ...auth });
      return;
    }
    await new Promise(r => setTimeout(r, 3000));
  }
  throw new Error("Container did not stop in time");
}

REST API Gotchas for Containers

  • .running field is the status indicator — values are strings "true" / "false", not booleans
  • No .stopped field exists — only check .running
  • Delete while stopping = HTTP 400 — must poll .running until "false" before DELETE
  • file= for local tar, remote-image= for registry pull
  • Container envlists= (plural, 7.20+) references the env list name — note the plural. Pre-7.20 used envlist= (singular). See env/mount version history above.

Container Properties (from 7.22)

Selected properties from /container/add. This is not exhaustive — use rosetta MCP tools (routeros_command_tree at /container/add) for the full list on a specific version.

Property Description
interface VETH interface
env Inline environment variables (7.21+). Comma-separated KEY=value pairs
envlists Named env list reference (7.20+). See env/mount section above
mount Inline volume mount (7.21+). src=host/path,dst=/container/path
mountlists Named mount list reference (7.21+). See env/mount section above
root-dir Storage location for container filesystem
file Container tar file (local import)
remote-image Container image name (registry pull)
cmd Override container CMD
entrypoint Override container ENTRYPOINT
hostname Container hostname
dns DNS server for container
logging Enable container stdout/stderr to RouterOS log (yes/no)
start-on-boot Auto-start container on device boot (yes/no)
workdir Override working directory
name Container name (for [find where name=...])
devices Pass through physical devices (7.20+)
cpu-list CPU core affinity
memory-high RAM usage limit in bytes

Architecture Mapping

When pulling from registries or building images, map RouterOS architecture to Docker platform:

RouterOS architecture-name Docker Platform
arm linux/arm/v7
arm64 linux/arm64
x86 linux/amd64

Query the router's architecture:

const resource = await fetch(`${base}/system/resource`, auth).then(r => r.json());
const arch = resource["architecture-name"]; // "arm64", "arm", "x86"

/app System (7.21+/7.22+)

RouterOS 7.21 introduced the /app path (built-in app listing). Full YAML app creation (/app/add) was added in 7.22. See the routeros-app-yaml skill for the full YAML specification.

# List available apps
/app/print

# Add app from URL
/app/add yaml-url=https://example.com/myapp.tikapp.yaml

/app vs Manual Container Setup

Concern Manual (this page) /app YAML
Networking Full control — any bridge/VETH/L2 topology Docker-style: internal subnet with port forwarding (NAT)
L2 bridge access Yes — add VETH + physical port to same bridge Not directly — but can assign a bridge post-creation via /app/set network=<bridge>
Multi-container Manual per-container setup Declarative YAML, multiple services
Use case Raw L2 access (netinstall, DHCP relay, etc.) Standard app deployment with port forwarding

Netinstall specifically requires L2 bridge access for BOOTP/TFTP, which is why the manual VETH+bridge approach is used rather than /app. For typical containers that only need port-forwarded TCP/UDP services, /app is simpler.

Additional Resources

Related skills:

  • For netinstall and device-mode automation: see the routeros-netinstall skill
  • For the /app YAML format: see the routeros-app-yaml skill
  • For general RouterOS fundamentals (CLI, REST, scripting): see the routeros-fundamentals skill

MCP tools:

  • For RouterOS documentation and property lookups: use the rosetta MCP server tools (routeros_search, routeros_get_page, routeros_search_properties)

External docs: