Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quotes on docker-compose.yml ports make any difference?

I don't know if there is a difference between ports with or without quotes in a docker-compose.yml file, can't find any good documentation.

  • With quotes
ports:
  - "80:80"
  - "443:443"
  • Without quotes
ports:
  - 80:80
  - 443:443

I see no difference when I run it

like image 304
LuisEnMarroquin Avatar asked Nov 12 '19 01:11

LuisEnMarroquin


People also ask

What is ports in docker-compose yml?

Ports is defined as: Either specify both ports (HOST:CONTAINER), or just the container port (a random host port will be chosen). Ports mentioned in docker-compose. yml will be shared among different services started by the docker-compose. Ports will be exposed to the host machine to a random port or a given port.

Does docker-compose expose ports?

Docker Compose exposes all specified container ports, making them reachable internally and externally from the local machine. Once again, in the PORTS column, we can find all the exposed ports. The value to the left of the arrow shows the host address where we can reach the container externally.

What does publishing ports in Docker accomplish?

Publishing a port makes it accessible from outside the container. It lets you take a port you've discovered by an EXPOSE instruction, then bind a host port to it. This command binds port 8080 on your Docker host to 80 inside your new container.


1 Answers

Note from Docker Compose file version 3 reference:

When mapping ports in the HOST:CONTAINER format, you may experience erroneous results when using a container port lower than 60, because YAML parses numbers in the format xx:yy as a base-60 value. For this reason, we recommend always explicitly specifying your port mappings as strings.

https://docs.docker.com/compose/compose-file/compose-file-v3/#ports

like image 161
Missael De Nadai Avatar answered Oct 19 '22 00:10

Missael De Nadai