Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I specify ports in a docker-compose.yml file, is it TCP or UDP?

I know that I can specify the protocol of "ports" in the docker-compose.yml file, but I am unsure what the default protocol is, if no protocol is specified.

Is it TCP? Is it UDP? Both?

I haven't been able to find the answer anywhere (including in the Docker Compose file reference).

like image 406
Mathias Lykkegaard Lorenzen Avatar asked Feb 04 '20 16:02

Mathias Lykkegaard Lorenzen


2 Answers

by default TCP is used, you can see it launching docker-compose ps

If you want to specify you should add /udp or /tcp like :

ports:
  - "80:80/udp"
  - "80:80/tcp"
like image 161
ctreton Avatar answered Oct 07 '22 18:10

ctreton


In addition to above comment for me docker compose long syntax worked to open udp port ,do also check that your required port is open and available to cater request. https://docs.docker.com/compose/compose-file/compose-file-v3/#ports

ports:
 - target: 18123
   published: 18123
   protocol: UDP
   mode: host
like image 33
SDV Avatar answered Oct 07 '22 18:10

SDV