Page tree

Container is MikroTik's own implementation of Docker(TM), allowing users to run containerized environments within RouterOS. The container feature was added in RouterOS v7.1rc3. 

Sub-menu: /container

Example with PiHole


    1. RouterOS device with RouterOS v7.1rc3 or later and installed Container package
    2. Computer with docker installed (for container file download)

Download PiHole's container files: 

            These links are latest  as of 7th of September, 2021. Please make sure to download the right version that matches Your RouterOS devices architecture.

	docker pull pihole/pihole:latest@sha256:1c02cda06ba1b997d10e0c12743002e845ed87bf010fca0ad838c3dba6ac6c58
	docker save pihole/pihole:latest > pihole.tar

	docker pull pihole/pihole:latest@sha256:381a39fc1a131e5fa1bb7e1ea6241147758c61206ffa851446a3737c61cf4162
	docker save pihole/pihole:latest > pihole.tar

	docker pull pihole/pihole:latest@sha256:31f2653d2a5fd56f14165fc9e51ba22338af99ac04eeaa2dea574810a76c0a01
	docker save pihole/pihole:latest > pihole.tar

     After file has been downloaded - upload it to Your RouterOS device.

Create a veth interface for Docker.

/interface/veth/add name=veth1 address= gateway=

Create a bridge for containers and add veth to it

/interface/bridge/add name=docker
/ip/address/add address= interface=docker
/interface/bridge/port add bridge=docker interface=veth1

Create enviromental variables

 0 list="pihole" name="TZ" value="Europe/Riga" 

 1 list="pihole" name="ServerIP" value="" 

 2 list="pihole" name="WEBPASSWORD" value="password1" 

Create mountpoints for non-volatile data (Configurations, etc)

This step is optional. 

 0 name="pihole" src="/pihole" dst="/etc/pihole" 

 1 name="dnsmasq.d" src="/dnsmasqd" dst="/etc/dnsmasq.d" 

Note: src=  points to RouterOS location (could also be src=disk1/pihole if, for example, You decide to put configuration files on external USB media), dst= points to defined location (consult containers manual/wiki/github for information on where to point). If src  directory does not exist on first time use then it will be populated with whatever container have in dst  location.

Create a container from tar image

/container/add file=pihole.tar interface=veth1 envlist=pihole mounts=pihole,dnsmasq.d hostname=PiHole

If You wish to see container output in log - add logging=yes 

If You wish to use external media for whole container storage - add root-dir=disk1/containers/pihole  (or location applicable to Your setup). For external media to work as whole container or mount storage, it has to be formatted as ext3 or ext4 .

Start container

Make sure container has been added and status=stopped by using /container/print 

/container/start 0

You should be able to access PiHole webpanel by navigating to  in your web browser.

  • No labels