Docker Deployment Ports already in use by Apache2

Summary
I am trying to deploy Mattermost with Docker, and it fails, because the Ports are already in use (Probably by Apache2). Can/Do I have to Change them?

Steps to reproduce
I am using the Latest Version, following this Guide with Docker.
The Error Occured while trying to get a Certificate with this Command:
bash scripts/issue-certificate.sh -d <YOUR_MM_DOMAIN> -o ${PWD}/certs
I then temporarly turned Apache2 off, and it worked.
Same Issue with trying to start the Mattermost Container with included NGINX:
sudo docker-compose -f docker-compose.yml -f docker-compose.nginx.yml up -d

Expected behavior
The Container/Server starts.

Observed behavior

After trying to start the Container/Server:

% sudo docker compose -f docker-compose.yml -f docker-compose.nginx.yml up -d
[+] Running 21/21
 ⠿ postgres Pulled                                                                                                                     15.8s
   ⠿ eb286326f602 Pull complete                                                                                                         3.1s
   ⠿ 63139c77dd7e Pull complete                                                                                                         3.5s
   ⠿ bcf0c6911552 Pull complete                                                                                                        13.6s
   ⠿ 9ccd67cfd6aa Pull complete                                                                                                        13.7s
   ⠿ d825238af7aa Pull complete                                                                                                        13.8s
   ⠿ 99e003736e16 Pull complete                                                                                                        13.8s
   ⠿ 616766a2f35e Pull complete                                                                                                        13.9s
 ⠿ mattermost Pulled                                                                                                                   19.1s
   ⠿ 751ef25978b2 Pull complete                                                                                                         2.0s
   ⠿ d6834836d8c9 Pull complete                                                                                                         3.9s
   ⠿ 51b297b9abe6 Pull complete                                                                                                        17.5s
   ⠿ c70ee9965cc3 Pull complete                                                                                                        17.6s
 ⠿ nginx Pulled                                                                                                                         6.6s
   ⠿ 8921db27df28 Pull complete                                                                                                         1.6s
   ⠿ 83e90619bc2e Pull complete                                                                                                         2.0s
   ⠿ d52adec6f48b Pull complete                                                                                                         2.1s
   ⠿ 10eb2ce358fa Pull complete                                                                                                         2.2s
   ⠿ a1be370d6a52 Pull complete                                                                                                         2.2s
   ⠿ 689b9959905b Pull complete                                                                                                         2.6s
   ⠿ c7a81ce22aac Pull complete                                                                                                         4.8s
[+] Running 4/5
 ⠿ Network mattermost             Created                                                                                               8.3s
 ⠿ Volume "shared-webroot"        Created                                                                                               0.0s
 ⠿ Container docker-postgres-1    Started                                                                                               7.4s
 ⠿ Container docker-mattermost-1  Started                                                                                              12.3s
 ⠿ Container nginx_mattermost     Starting                                                                                             14.1s
Error response from daemon: driver failed programming external connectivity on endpoint nginx_mattermost (74d26544afc9053de4d455602f2c157e82afc263d23ce31c47a077c0b3898f7d): Error starting userland proxy: listen tcp4 0.0.0.0:443: bind: address already in use

Hi @BenMajestix and welcome to the Mattermost forums!

Only one application can occupy a single port, so if you have already something else running on port 443 or 80 (which are the default exposed ports for the Mattermost deployment); you will not be able to start the containers.

Please check what applications run on these ports on your system currently, you can do so with the following commands:

lsof -i :443
lsof -i :80

Since you said you’ve turned off Apache2, it probably is Apache2 which is now listening on these ports and blocking them and you will have to decide if you want to continue to use Apache on this server or Mattermost, if both should have the same port.
Alternatively, you can also change the exposed ports for Mattermost to something else (8080 and 8443, f.ex.), if those ports are free on your system, but your users will then have to also access Mattermost using these ports (f.ex. https://yourserver.yourdomain.com:8443).

If you’re trying to add Mattermost to an already existing server and Apache should be the main webserver on this system, you could use it as a [reverse proxy for Mattermost]/Configuring Apache2 as a proxy for Mattermost Server (Unofficial) — Mattermost documentation). In this case, you will not need the nginx container and also will not need to handle the certificates from within the Mattermost environment, but this configuration is not officially supported.