<p>Do you have network constraints to create a new subnet or what is the reason?
if it's not useful at all, you can just map the port and open the firewall of your PC so that the other machines can see the application.</p>
<pre class="lang-yaml prettyprint-override"><code>version: '3' 
services:
  nextclouddb:
    image: mariadb
    container_name: nextcloud-mariadb
    volumes:
      - /home/username/data/mysql:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MYSQL_ROOT_PASSWORD=STONGPASSWORD
      - MYSQL_PASSWORD=ANOTHERSTONGPASSWORD
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    restart: unless-stopped
  
  nextcloudapp:
    image: nextcloud:latest
    container_name: nextcloud-app
    volumes:
      - /home/username/data/html:/var/www/html
      - /home/username/data/config:/var/www/html/config
      - /home/username/data/apps:/var/www/html/custom_apps
      - /home/username/data/data:/var/www/html/data
      - /home/username/data/themes:/var/www/html/themes
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    ports:
      - 2287:80  
</code></pre>

CC BY-SA 4.0
2021-03-23T14:12:27.447Z
2021-03-23T14:12:27.447Z
lzarus
<p>I'm deploying nextcloud via docker, however the way the configuration is set up, it creates a subnetwork at 10.10.10.0/24 on the system it's running on instead of running it on 127.0.0.1. Then the only way to access it is by navigating to 10.10.0.5 on the host machine.</p>
<p>However, I want to be able to access this image from every machine on my local network.</p>
<p>I already have a few things running, so I need to map the port as well.</p>
<p>Is there an intuitive way to map the network such that navigating to 127.0.0.1:2287 maps it to 10.10.0.5? I can't seem to find anything indicating how to do this.</p>
<p>I would think this would have to be a bidirectional mapping since it needs to send data back since it's nextcloud, but I'm unsure about this.</p>
<p>I did try setting up the docker container to report to 127.0.0.1 but it didn't work out. It would only report on 172.19.0.5</p>
<p>If you wanted to see my docker setup, it's as follows:</p>
<ol>
<li><p>Create the subnetwork for docker: <code>docker network create --driver=bridge --subnet=10.10.10.0/24 --gateway=10.10.10.1 dockernet</code></p>
</li>
<li><p>Run docker-compose</p>
</li>
</ol>
<pre><code>version: '3' 

services:
  nextclouddb:
    image: mariadb
    container_name: nextcloud-mariadb
    volumes:
      - /home/username/data/mysql:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    networks:
      default:
        ipv4_address: 10.10.10.4
    environment:
      - MYSQL_ROOT_PASSWORD=STONGPASSWORD
      - MYSQL_PASSWORD=ANOTHERSTONGPASSWORD
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    restart: unless-stopped
  
  nextcloudapp:
    image: nextcloud:latest
    container_name: nextcloud-app
    networks:
      default:
        ipv4_address: 10.10.10.5
    volumes:
      - /home/username/data/html:/var/www/html
      - /home/username/data/config:/var/www/html/config
      - /home/username/data/apps:/var/www/html/custom_apps
      - /home/username/data/data:/var/www/html/data
      - /home/username/data/themes:/var/www/html/themes
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped

networks:
  default:
    external:
      name: dockernet
</code></pre>

CC BY-SA 4.0
2021-03-21T19:41:35.990Z
Are you trying to map local port to a specific internal port - perhaps try the [Connect a container to a user-defined bridge](https://docs.docker.com/network/bridge/)
Mr R
CC BY-SA 4.0
2021-03-23T14:16:53.807Z
You should re read docker documentation, docker networks are aimed at allowing inter container communications, docker is about isolation of processes, including what port they're listining on, if a port is to be exposed to the external world, well it has to be exposed on the docker host.
Tensibai
<docker><docker-compose><containers><networking>
How to create a local network mapping in linux
Cmertin
# How to create a local network mapping in linux

(Asked by: username_0 on 2021-03-21)

I'm deploying nextcloud via docker, however the way the configuration is set up, it creates a subnetwork at 10.10.10.0/24 on the system it's running on instead of running it on 127.0.0.1. Then the only way to access it is by navigating to 10.10.0.5 on the host machine.
However, I want to be able to access this image from every machine on my local network.
I already have a few things running, so I need to map the port as well.
Is there an intuitive way to map the network such that navigating to 127.0.0.1:2287 maps it to 10.10.0.5? I can't seem to find anything indicating how to do this.
I would think this would have to be a bidirectional mapping since it needs to send data back since it's nextcloud, but I'm unsure about this.
I did try setting up the docker container to report to 127.0.0.1 but it didn't work out. It would only report on 172.19.0.5
If you wanted to see my docker setup, it's as follows:

Create the subnetwork for docker: docker network create --driver=bridge --subnet=10.10.10.0/24 --gateway=10.10.10.1 dockernet

Run docker-compose


version: '3' 

services:
  nextclouddb:
    image: mariadb
    container_name: nextcloud-mariadb
    volumes:
      - /home/username/data/mysql:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    networks:
      default:
        ipv4_address: 10.10.10.4
    environment:
      - MYSQL_ROOT_PASSWORD=STONGPASSWORD
      - MYSQL_PASSWORD=ANOTHERSTONGPASSWORD
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    restart: unless-stopped
  
  nextcloudapp:
    image: nextcloud:latest
    container_name: nextcloud-app
    networks:
      default:
        ipv4_address: 10.10.10.5
    volumes:
      - /home/username/data/html:/var/www/html
      - /home/username/data/config:/var/www/html/config
      - /home/username/data/apps:/var/www/html/custom_apps
      - /home/username/data/data:/var/www/html/data
      - /home/username/data/themes:/var/www/html/themes
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped

networks:
  default:
    external:
      name: dockernet

**Tags:** docker, docker-compose, containers, networking

> **Comments:**
> **username_1**: Are you trying to map local port to a specific internal port - perhaps try the [Connect a container to a user-defined bridge](https://docs.docker.com/network/bridge/)  
> **username_2**: You should re read docker documentation, docker networks are aimed at allowing inter container communications, docker is about isolation of processes, including what port they're listining on, if a port is to be exposed to the external world, well it has to be exposed on the docker host.  

---

## 1 answers

### Answer by username_3 on 2021-03-23. Score: 1

Do you have network constraints to create a new subnet or what is the reason?
if it's not useful at all, you can just map the port and open the firewall of your PC so that the other machines can see the application.
version: '3' 
services:
  nextclouddb:
    image: mariadb
    container_name: nextcloud-mariadb
    volumes:
      - /home/username/data/mysql:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MYSQL_ROOT_PASSWORD=STONGPASSWORD
      - MYSQL_PASSWORD=ANOTHERSTONGPASSWORD
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    restart: unless-stopped
  
  nextcloudapp:
    image: nextcloud:latest
    container_name: nextcloud-app
    volumes:
      - /home/username/data/html:/var/www/html
      - /home/username/data/config:/var/www/html/config
      - /home/username/data/apps:/var/www/html/custom_apps
      - /home/username/data/data:/var/www/html/data
      - /home/username/data/themes:/var/www/html/themes
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    ports:
      - 2287:80


---

