Community discussions

MikroTik App
 
NHosseinzadeh
just joined
Topic Author
Posts: 2
Joined: Fri Mar 03, 2023 6:41 pm

Container publish or expose port (-p)

Sat Dec 23, 2023 7:42 am

Hi, some container images and docker applications require -p command to set the port of application/container and map it to the host (ros). i know that i can use DST NAT to expose(map) a container to outside, but how could i define the application port number running inside the container.
consider this for example:
docker run -d \
--name mtproxy \
--restart=always \
-e domain="cloudflare.com" \
-e secret="548593a9c0688f4f7d9d57377897d964" \
-e ip_white_list="OFF" \
-p 8080:80 \
-p 8443:443 \
ellermister/mtproxy
if we don't define the port, the application inside the container may not start listening on any port or it will use a random one(maybe).
thanks for the help
Navid
 
User avatar
antonsb
MikroTik Support
MikroTik Support
Posts: 388
Joined: Sun Jul 24, 2016 3:12 pm
Location: Riga, Latvia

Re: Container publish or expose port (-p)

Wed Dec 27, 2023 6:31 pm

-p flag in docker maps ports in similar way as dst-nat does in MikroTik. Container should not care about -p parameter, as it's done on network layer above it.
 
tangent
Forum Guru
Forum Guru
Posts: 1420
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: Container publish or expose port (-p)

Thu Dec 28, 2023 10:57 pm

To add to @antonsb's answer, dstnat rules allow you to map one port number to another, same as Docker's `-p` flag.

Indeed, Docker's default network is a NAT system, and its `-p` flag does this same type of dstnat mapping. RouterOS's container runtime has many differences from Docker's, but in this case, it's an exact 1:1 mapping. You don't need MikroTik to add anything new here.

Who is online

Users browsing this forum: No registered users and 1 guest