Issue to expose Port

Hello,

I am using Portainer to deploy Docker containers and I am pulling the docker-compose.yml in conjunction with a stack.env from a Git account.

Unfortunately, I am unable to expose a port. I have tried assigning the ports in the standard way (ports: - 80:8080), in the detailed format (target: 5216 and publish), and by creating an environment variable through the stack.env (internal_port, exposed_port). While the variables are created, they are not utilized. In all cases, the ports section remains empty ({}) when I inspect the container. Other than that, I have no issues.

A special feature is that I am using a macvlan, which I integrate into the respective container.

Can you help me?

Example of my compose:

services:
  nameofservice:
    container_name: nameofservice
    image: image:latest
    env_file:
      - stack.env
    restart: always
    networks:
      macvlan_net:
        ipv4_address: 10.10.10.xx
    ports:
      - target: 8080
        published: 80
    security_opt:
      - apparmor=docker-default
    volumes:
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - volumen-data:/data

networks:
  macvlan_net:
    external: true

volumes:
  volumen-data:
    external: true

A chatbot thinks you can’t expose ports the Docker way, as macvlan will bypass the Docker network stack.

Ports of the container app should be open by default, but they won’t be shown as ports in Docker.