Mapping
Vagrant
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "ubuntu/bionic64"
config.vm.network "forwarded_port", guest: 8123, host: 8080
end
Docker Compose
確保端口号之间沒有空格
Nginx
Vagrant 端口映射: 宿主机的 8080 端口映射到虚拟机的 8123 端口。
Docker Compose 端口映射: 虚拟机的 8123 端口映射到 Docker 容器内部的 8801 端口。
Nginx 配置: Nginx 服务监听 8801 端口。
通过这些配置,通过 http://localhost:8080 访问到在 Vagrant 虚拟机内运行的 Docker 容器中的 Nginx 服务。