How do you map ports to a specific service container in Docker Compose?

Experience Level: Senior
Tags: Docker Compose

Answer

Use ports: property of your service.

version: "3.9"
services:
  my-service:
    image: mssql
    ports: 8000:1433

The first port is a host port, the second port is a container port.

Comments

No Comments Yet.
Be the first to tell us what you think.
Docker Compose
Docker Compose

Are you learning Docker Compose ? Try our test we designed to help you progress faster.

Test yourself