What is a container?
A container is a very lightweight virtual machine with direct but controlled access to system resources. For decades there’s been a need to run programs written for one operating system on another, which is one of the main reasons emulation software exists. In this article we’ll install and run an Ubuntu container on MikroTik.
Docker
You’ve probably heard of Docker, the tool that made containers popular. Docker uses kernel features to build and manage lightweight, controlled containers. It has a client and a service that must be running on the system, plus an online hub where ready-made images are built, published and stored. This is known as a container registry.
Why Linux containers?
Say you want to develop an app on your laptop. You need an environment with specific tools that’s easy to access, and that’s exactly what containers provide.
- Low resource use and high speed: containers share the operating system kernel and use resources efficiently.
- Strong security: each container runs isolated from the others, which improves security and reduces conflicts between programs.
- Resource management: containers let you use tools such as cgroups to manage resources on your server precisely and easily.
- Compatibility: containers let you run programs on different systems, such as MikroTik, without major changes.
- A wide range of tools: containers work with most tools, giving server administrators a lot of flexibility.
Installing an Ubuntu container on MikroTik
First you need a server. Then download the MikroTik packages needed to install containers.
Once they’re downloaded, connect to your MikroTik server with WinBox. Upgrade RouterOS to 7.7, then upload the 7.7 container package to Files in the left-hand menu (as shown below).

Reboot the system from System > Reboot, and once the server is back up, run the following command in the terminal:
/system/device-mode/update container=yes
You’ll see output like the image below. To confirm enabling containers, you need to power the server off and on again (you have 5 minutes to do so).

Set DNS servers on the MikroTik router
Because of sanctions, servers in Iran can’t always reach Docker Hub directly, so we use anti-sanctions DNS servers. Go to IP > DNS in the left-hand menu and enter them under Servers:
DNS: 178.22.122.100, 185.51.200.2

Set up networking and the container registry
In the MikroTik terminal, run the following commands to configure networking for Docker containers. First, create a virtual interface:
/interface/veth/add name=veth2 address=172.17.1.2/24 gateway=172.17.1.1
Next, create a bridge:
/interface/bridge/add name=dockers2 protocol-mode=none
Then run these commands in order:
/ip/address/add address=172.17.1.1/24 interface=dockers2
/interface/bridge/port add bridge=dockers2 interface=veth2
/ip/firewall/nat/add chain=srcnat action=masquerade src-address=172.17.1.0/24
/container/config/set registry-url=https://registry-1.docker.io tmpdir=disk1/pull
1. Install Linux on MikroTik
To use the Ubuntu container, pull the Ubuntu image with the command below and wait for it to finish:
/container add remote-image=victorvidal/ubuntu-systemctl interface=veth2 root-dir=disk1/ubuntu logging=yes
2. Start the container
Start the container from the MikroTik terminal with:
/container/start 0
Note that whenever the server restarts, the container goes back to the stopped state, so you’ll need to start it again with this command.
3. Connect to the Ubuntu container
To open a shell inside your container, use:
/container/shell 0
You can see the installed container under Container in the left-hand menu (as shown below).

Conclusion
In this guide we introduced Docker and containers and set one up. A container is operating-system-level virtualization that shares the host’s kernel. Thanks for reading this guide to running an Ubuntu container on MikroTik, and follow Mizbandade for more.

