title: Connecting to Docker from external network: modifying YML file
body: <p>I am trying to set up a Learning Locker server within Docker (on Windows 10, Docker using WSL for emulation) using the repo from <a href="https://github.com/michzimny/learninglocker2-docker" rel="nofollow noreferrer">michzimney</a>. This service is composed of several Docker containers (Mongo, Redis, NGINX, etc) networked together. Using the provided <code>docker-compose.yml</code> file I have been able to set up the service and access it from localhost, but I cannot access the server from any machine on the rest of my home network.</p>
  <p>This is a specific case, but some guidance will be valuable as I am very new to Docker and <strong>will need to build many such environments in the future</strong>, for now in Windows but later in Docker on Synology, <strong>where the services can be access from network and internet</strong>.</p>
  <p>My research has led me to <a href="https://stackoverflow.com/questions/54290623/docker-access-from-other-machines-on-local-network">user-defined bridging</a> using <code>docker -p [hostip]:80:80</code> but this didn't work for me. I have also turned off Windows firewall since that seems to cause a host of issues for some but still no effect. I tried to <a href="https://stackoverflow.com/questions/61002681/connecting-to-wsl2-server-via-local-network">bridge my virtual switch manager for WSL</a> using Windows 10 Hyper-V manager, but that didn't work, and I have tried <a href="https://stackoverflow.com/questions/39111247/how-to-access-docker-container-from-another-machine-on-local-network">bridging the WSL connector to LAN using basic Windows 10 networking</a> but that didn't work and I had to reset my network.</p>
  <ul>
  <li>So the <strong>first question</strong> is is this a Windows networking issue or a
  Docker configuration issue?</li>
  <li>The <strong>second question</strong>, assuming it's a
  Docker configuration issue, is how can I modify the following YML
  file to make the service accessible to the outside network:</li>
  </ul>
  <pre><code>version: '2'
  services:
  
     mongo:
         image: mongo:3.4
         restart: unless-stopped
         volumes:
             - &quot;${DATA_LOCATION}/mongo:/data/db&quot;
  
     redis:
         image: redis:4-alpine
         restart: unless-stopped
  
     xapi:
         image: learninglocker/xapi-service:2.1.10
         restart: unless-stopped
         environment:
             - MONGO_URL=mongodb://mongo:27017/learninglocker_v2
             - MONGO_DB=learninglocker_v2
             - REDIS_URL=redis://redis:6379/0
         depends_on:
             - mongo
             - redis
         volumes:
             - &quot;${DATA_LOCATION}/xapi-storage:/usr/src/app/storage&quot;
  
     api:
         image: michzimny/learninglocker2-app:${DOCKER_TAG}
         environment:
             - DOMAIN_NAME
             - APP_SECRET
             - SMTP_HOST
             - SMTP_PORT
             - SMTP_SECURED
             - SMTP_USER
             - SMTP_PASS
         command: &quot;node api/dist/server&quot;
         restart: unless-stopped
         depends_on:
             - mongo
             - redis
         volumes:
             - &quot;${DATA_LOCATION}/app-storage:/opt/learninglocker/storage&quot;
  
     ui:
         image: michzimny/learninglocker2-app:${DOCKER_TAG}
         environment:
             - DOMAIN_NAME
             - APP_SECRET
             - SMTP_HOST
             - SMTP_PORT
             - SMTP_SECURED
             - SMTP_USER
             - SMTP_PASS
         command: &quot;./entrypoint-ui.sh&quot;
         restart: unless-stopped
         depends_on:
             - mongo
             - redis
             - api
         volumes:
             - &quot;${DATA_LOCATION}/app-storage:/opt/learninglocker/storage&quot;
             - &quot;${DATA_LOCATION}/ui-logs:/opt/learninglocker/logs&quot;
  
     worker:
         image: michzimny/learninglocker2-app:${DOCKER_TAG}
         environment:
             - DOMAIN_NAME
             - APP_SECRET
             - SMTP_HOST
             - SMTP_PORT
             - SMTP_SECURED
             - SMTP_USER
             - SMTP_PASS
         command: &quot;node worker/dist/server&quot;
         restart: unless-stopped
         depends_on:
             - mongo
             - redis
         volumes:
             - &quot;${DATA_LOCATION}/app-storage:/opt/learninglocker/storage&quot;
  
     nginx:
         image: michzimny/learninglocker2-nginx:${DOCKER_TAG}
         environment:
             - DOMAIN_NAME
         restart: unless-stopped
         depends_on:
             - ui
             - xapi
         ports:
             - &quot;443:443&quot;
             - &quot;80:80&quot;
  </code></pre>
  <p>So far I have attempted to change the <code>ports</code> option to the following:</p>
  <pre><code>        ports:
              - &quot;192.168.1.102:443:443&quot;
              - &quot;192.168.1.102:80:80&quot;
  </code></pre>
  <p>But then the container wasn't even accessible from the host machine anymore. I also tried adding <code>network-mode=host</code> under the nginx service but the build failed saying it was not compatible with port mapping. Do I need to set <code>network-mode=host</code> for every service or is the problem something else entirely?</p>
  <p>Any help is appreciated.</p>