I am trying to install NetBox using Docker Compose following the official repository: NetBox Docker.
The quickstart guide suggests adding a docker-compose.override.yml with the following configuration:
The quickstart guide suggests adding a docker-compose.override.yml with the following configuration:
services:
netbox:
ports:
- "8000:8080"
I followed this method, and it works fine.
However, I want to define the port mapping directly in docker-compose.yml instead of using an override file. I attempted to add the ports section under servicesbox in docker-compose.yml, but it is not working.
Here’s the relevant part of my docker-compose.yml:
services:
netbox: &netbox
image: docker.io/netboxcommunity/netbox:${VERSION-v4.2-3.1.1}
depends_on:
- postgres
- redis
- redis-cache
env_file: env/netbox.env
user: "unit:root"
healthcheck:
test: curl -f http://localhost:8080/login/ || exit 1
start_period: 90s
timeout: 3s
interval: 15s
ports:
- 8000:8080
volumes:
- ./configuration:/etc/netbox/config:z,ro
- netbox-media-files:/opt/netbox/netbox/media:rw
- netbox-reports-files:/opt/netbox/netbox/reports:rw
- netbox-scripts-files:/opt/netbox/netbox/scripts:rw
After running docker-compose up, the NetBox container starts, but I am unable to access it via http://localhost:8000. It seems like the port mapping is not applied.
Questions: Is there a specific reason why port mapping works in docker-compose.override.yml but not in docker-compose.yml? Am I missing any required configuration in docker-compose.yml to make this work? Any help would be appreciated!