How to Change the Port for a Service in Docker Compose?

0
0
Asked By BlueSky88 On

I'm having trouble changing the port for a service in my Docker Compose file. I want to deploy the 'homepage' service which defaults to port 3000, but that port is already in use by my AdGuard. I need to set it to a different port, but I'm not sure how to configure this in my docker-compose.yml file. Here's a snippet of what I have:

services:
homepage:
image: ghcr.io/gethomepage/homepage:latest
ports:
- 3000:3000

I've tried changing it to 3030:3030 and even 9644:9644, but I'm not sure if I'm doing it right. Any guidance would be really appreciated!

3 Answers

Answered By HelpfulHarry On

To reiterate what the others said, it’s crucial to match the container port to what the service uses inside. If your service is listening on port 3000, then your host port can be changed freely, just ensure it’s not the same as another service!

Answered By DockerNovice42 On

Make sure you're clear on the port mapping concept! It’s always :. The container is listening on port 3000, so keep that on the right side when changing the left.

Answered By TechieGuru92 On

You just need to change the left side of the port mapping in your Docker Compose file. The format is `:`, so you can switch it to something like 3030:3000 or 9644:3000 to free up port 3000 for your AdGuard.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.