Virtualbox/Swarm - NAT and HOSTonly Network

Hi Guys,

I’m quite new in docker world.

I have a local virtulbox setup:

vm1=swarm manager (mysql,visualizer) IP: 192.168.99.100
vm2= wordpress service IP: 192.168.99.101

I can reach the application on both IP’s 100/101. But I would like to also use the localhost in order to port forward localhost to NET since 192.168.99.0 subnet is HOST only.

In VBOX I have portforwarding set like this for the NAT interface on the machine where apache runs:
HOST PORT 8888 / GUEST PORT 8888

Currently the YAML looks like this:

    version: '3.4'

services:

  wordpress:
    image: wordpress
    depends_on:
      - mysql
      - wordpress
    deploy:
      placement:
        constraints: [node.labels.application==true]
      mode: replicated
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: on-failure
    ports:
      - "80:80"
    environment:
      WORDPRESS_DB_PASSWORD: "12345"
    networks:
      - wordpress_net

  mysql:
    image: mysql:latest
    volumes:
      - "/mnt/sda1/var/lib/docker/volumes/mysql_data/_data:/var/lib/mysql"
    deploy:
      placement:
        constraints: [node.role == manager]
    environment:
      MYSQL_ROOT_PASSWORD: "12345"
    networks:
      - wordpress_net

  visualizer:
    image: dockersamples/visualizer:stable
    ports:
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    deploy:
      placement:
        constraints: [node.role == manager]
    networks:
      - wordpress_net

networks:
  wordpress_net:

How can I attach the eth0 interface to container. So both the swarm network and the NAT-ed network will be reachable ?

I was trying something like this but without success:

services:

  wordpress:
    image: wordpress
    depends_on:
      - mysql
      - wordpress
    deploy:
      placement:
        constraints: [node.labels.application==true]
      mode: replicated
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: on-failure
    ports:
      - target: 80
        published: 80
        protocol: tcp
        mode: ingress
      - target: 80
        published: 8888
        protocol: tcp
        mode: host
    environment:
      WORDPRESS_DB_PASSWORD: "12345"
    networks:
      - wordpress_net

Thanks !