Docker Containers on MikroTik RouterOS 7: Setup Guide

RouterOS 7 can run containers from Docker images right on the router. That lets you host small services on a MikroTik — the Pi-hole ad blocker, a monitoring agent, a proxy or your own script — without a separate computer. There is no full Docker inside: RouterOS uses its own implementation that is compatible with OCI images.
Requirements and limits
- RouterOS 7.4 or newer. Use the current stable release: the container command syntax has changed between versions.
- Architecture: arm, arm64 or x86. The last one includes the CHR cloud router on a VPS. The image must be built for the device’s architecture.
- External storage. The router’s built-in flash is small and wears out quickly under frequent writes. Use a USB drive or NVMe; on CHR, a separate virtual disk.
- RAM. Containers consume the router’s memory. Do not run them on devices with 256 MB.
Step 1. Install the container package
- On mikrotik.com, download the Extra packages archive for your architecture and RouterOS version.
- Unpack it and upload the
container-*.npkfile to the router’s Files section. - Reboot the router:
/system/reboot
After the reboot a Container menu appears.
Step 2. Enable container mode
/system/device-mode/update container=yes
The router asks you to confirm: within the time shown, press the reset button on the case or power-cycle the device. On CHR, shut the virtual machine down from the control panel and start it again. This protects against an attacker enabling the feature remotely.
Check the result:
/system/device-mode/print
Step 3. Prepare the disk
Format the external drive as ext4 and look up its name:
/disk/print
/disk/format-drive usb1 file-system=ext4
Formatting destroys all data on the drive. The examples below call the drive disk1 — use your own name.
Step 4. Set up container networking
A container connects to the router through a virtual veth interface. Create a separate bridge and subnet:
/interface/veth/add name=veth1 address=172.17.0.2/24 gateway=172.17.0.1
/interface/bridge/add name=containers
/ip/address/add address=172.17.0.1/24 interface=containers
/interface/bridge/port add bridge=containers interface=veth1
Add a NAT rule so the container can reach the internet:
/ip/firewall/nat/add chain=srcnat action=masquerade src-address=172.17.0.0/24
Step 5. Set the image registry
/container/config/set registry-url=https://registry-1.docker.io tmpdir=disk1/tmp
tmpdir is the directory for temporary files while pulling an image. It must be on the external disk.
Step 6. Start a container
The example is Pi-hole, a DNS server that blocks ads.
Set the environment variables:
/container/envs/add list=ENV_PIHOLE key=TZ value="Europe/Kyiv"
/container/envs/add list=ENV_PIHOLE key=FTLCONF_webserver_api_password value="a-strong-password"
/container/envs/add list=ENV_PIHOLE key=DNSMASQ_USER value="root"
Define persistent directories — without them the settings are lost when the container is recreated:
/container/mounts/add list=MOUNT_PIHOLE_PIHOLE src=disk1/volumes/pihole/pihole dst=/etc/pihole
/container/mounts/add list=MOUNT_PIHOLE_DNSMASQD src=disk1/volumes/pihole/dnsmasq.d dst=/etc/dnsmasq.d
Create the container:
/container/add remote-image=pihole/pihole interface=veth1 root-dir=disk1/images/pihole mountlists=MOUNT_PIHOLE_PIHOLE,MOUNT_PIHOLE_DNSMASQD envlist=ENV_PIHOLE name=pihole start-on-boot=yes logging=yes
The router starts pulling and extracting the image. Watch the status:
/container/print
When the status changes to stopped, start the container:
/container/start pihole
Step 7. Reach the service
From the local network the container is available at 172.17.0.2, provided the firewall allows traffic between the networks. To open the web interface on the router’s own address, forward a port:
/ip/firewall/nat/add chain=dstnat action=dst-nat dst-address=192.168.88.1 dst-port=8080 protocol=tcp to-addresses=172.17.0.2 to-ports=80
For Pi-hole, the remaining step is to set 172.17.0.2 as the DNS server in the router’s DHCP settings.
Managing containers
/container/print # list and status
/container/start pihole # start
/container/stop pihole # stop
/container/shell pihole # shell inside the container
/container/remove pihole # remove
/log/print where topics~"container" # log
To update an image, stop and remove the container, then create it again with the same command. Data in the mounted directories is kept.
What makes sense to run on a router
Lightweight network services fit well: Pi-hole or AdGuard Home, a tunnel client, a small web server, a monitoring agent. Databases, media servers and anything that writes to disk heavily or needs a lot of memory belong on a separate server with full Docker — see the installation guide.
Common problems
- No Container menu. The
containerpackage is not installed, or its version does not match RouterOS. - Container commands are unavailable. Device mode was not confirmed: repeat step 2.
- The image does not download. The container network has no internet access, or DNS is not configured on the router. Check the NAT rule and
/ip/dns/print. - Image format error. The image is not built for the router’s architecture.
- The container starts and stops immediately. Enable
logging=yesand read the log: usually it is out of memory or a required environment variable is missing.
Security
- Keep containers in their own subnet and restrict their access to the local network with firewall rules — the basics are in the MikroTik firewall guide.
- Do not forward container ports to the internet unless you have to.
- Update RouterOS and the images regularly.
Video walkthrough
The video was recorded for an earlier RouterOS release: some commands have changed since, but the overall procedure is the same.



