Regarding Traefik image building

Got to know that traefik supports both the ports 80 and 8080 but in a image only one port can be exposed.
How traffik image created to support both the ports. Can some one please share the image creation steps of the Traefik. Need to know the detail steps of the traefik image creation.

An image can expose multiple ports/proto by using multiple EXPOSE statements:

As explained in the link Exposed does not mean published. And you can also publish multiple ports/protocols.

The Dockerfile for the image is in git.

Thanks for the information ..
Basicallly right now if the image created with the below statement then able to access the application through port 8080 but not with port 80, for port 80 need to delete this statement.Is there a way to taken care of this scenario at run time ? i.e after the image created.

sed -i -e "s;Listen 80;Listen 8080;" /etc/httpd/conf/httpd.conf

I'm not sure what you are trying to accomplish but is seems more relevant to a docker forum then Traefik.

Unless you are trying to build your own Traefik image ?

I also would like to add that unless I'm mistaken "EXPOSE" does not actually do anything except creating metadata. It does not affect which ports are exposed and which are not.

Pretty much. It allows you to use the -P docker option, basically useless day to day though.

The EXPOSE instruction does not actually publish the port. It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published. To actually publish the port when running the container, use the -p flag on docker run to publish and map one or more ports, or the -P flag to publish all exposed ports and map them to high-order ports.

This Docker file Doesnot have much info on how traefik image built to supports multiple ports.
Can you please share more info on this docker file used to built the traefik image

There is nothing 'special' done, this is just how docker works. The ports published to a container are done using docker's -p flag. Or using ports in docker compose.

As I mentioned previously, this is better asked on a docker forum.

1 Like