我在码头世界里很新。
我有一个本地的virtulbox设置:
vm1 = swarm manager(mysql,visualizer)IP:192.168.99.100
vm2 = wordpress服务IP:192.168.99.101
我可以在IP 100/101上访问该应用程序。但是我也想使用localhost来将localhost转发到.NET,因为192.168.99.0子网只是HOST。
在VBOX中,我为这个运行apache的机器上的NAT接口设置了这样的端口转发:
HOST PORT 8888 / GUEST PORT 8888
目前YAML看起来像这样:
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:
如何将eth0接口附加到容器。那么群网和NAT网络都可以访问吗?
我正在尝试这样的事情,但没有成功:
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
谢谢!