EvilFreelancer / docker-routeros

Mikrotik RouterOS inside Docker container
https://hub.docker.com/r/evilfreelancer/docker-routeros/
MIT License
369 stars 132 forks source link
container docker docker-container docker-image mikrotik qemu routeros

Mikrotik RouterOS in Docker

This project comprises a Docker image that runs a MikroTik's RouterOS virtual machine inside QEMU.

It's designed to simulate MikroTik's RouterOS environment, making it an excellent tool for development and testing purposes, especially for those working with the RouterOS API.

This Docker image is particularly useful for unit testing the routeros-api-php library, allowing developers to test applications in a controlled environment that closely mimics a real RouterOS setup.

For users seeking a fully operational RouterOS environment for production use within Docker, the VR Network Lab project is recommended as an alternative.

Getting Started

Pulling the Image from Docker Hub

To use the image directly from Docker Hub, you can pull it and run a container as shown below. This will start a RouterOS instance with ports configured for SSH, API, API-SSL, and VNC access.

docker pull evilfreelancer/docker-routeros
docker run -d -p 2222:22 -p 8728:8728 -p 8729:8729 -p 5900:5900 -ti evilfreelancer/docker-routeros

Use in docker-compose.yml

For those preferring docker-compose, an example configuration is provided below. More examples is here.

version: "3.9"
services:
  routeros:
    image: evilfreelancer/docker-routeros:latest
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun
      - /dev/kvm
    ports:
      - "2222:22"
      - "23:23"
      - "80:80"
      - "5900:5900"
      - "8728:8728"
      - "8729:8729"

Creating a Custom Dockerfile

You can easily create your own Dockerfile to include custom scripts or configurations. The Docker image supports various tags, which are listed here. By default, the latest tag is used if no tag is specified.

FROM evilfreelancer/docker-routeros
ADD ["your-scripts.sh", "/"]
RUN /your-scripts.sh

Building from Source

If you prefer to build the Docker image from source, the commands below will guide you through cloning the repository, building the image, and running a RouterOS container.

git clone https://github.com/EvilFreelancer/docker-routeros.git
cd docker-routeros
docker build . --tag ros
docker run -d -p 2222:22 -p 8728:8728 -p 8729:8729 -p 5900:5900 -ti ros

After launching the container, you can access your RouterOS instance via VNC (port 5900) and SSH (port 2222).

Exposed Ports

The table below summarizes the ports exposed by the Docker image, catering to various services and protocols used by RouterOS.

Description Ports
Defaults 21, 22, 23, 80, 443, 8291, 8728, 8729
IPSec 50, 51, 500/udp, 4500/udp
OpenVPN 1194/tcp, 1194/udp
L2TP 1701
PPTP 1723

Links

For more insights into Docker and virtualization technologies related to RouterOS and networking, explore the following resources: