Check the running containers ID and port numbers by running the docker container ls command
In the above example, you can see sitecore-xp0-cm
container image is running on port 80, now you can map port 80 of the container to the host machine port. Make sure the host machine port is not in already use.
In your Sitecore docker set-up folder, open the docker-compose.yml
file in the notepad editor. Check the CM container configuration section and add a ports node like the below screenshot. The first port is the localhost port and the second port is the container port.
cm:
isolation: ${ISOLATION}
image: ${SITECORE_DOCKER_REGISTRY}sitecore-xp0-cm:${SITECORE_VERSION}
ports:
- "8001:80"
depends_on:
id:
condition: service_started
xconnect:
condition: service_started
[...]
Now once you'll run the containers, CM container is accessible via localhost:8001.
Any other machine on the same network can access port 8001 of the host machine, and they will be able to access the CM container.
You can find more details here: https://sitecorewithraman.wordpress.com/2023/03/26/access-sitecore-docker-container-from-another-machine-on-local-network/