我在windows 7上的Vagrant VM(VirtualBox)中运行docker。一切工作正常,我通过docker-compose成功设置了几个容器。 容器可以通过从docker-compose文件映射服务名称的逻辑主机名访问自己。
有没有什么办法可以通过这些逻辑主机名来访问容器,而不仅仅是容器本身,而且还来自:
主机运行docker守护程序
Vagrant的虚拟主机(我的windows运行所有这一切)
通过这种方式,我不必为从顶层窗口主机和目标容器交互configuration直接执行的应用程序维护单独的configuration。
简而言之:“Ping mongo”只有在从docker容器中运行时才会到达主机。 我很想设置它,所以它会从Ubuntu主机和顶级windows主机工作…
我的stream浪文件:
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure(2) do |config| config.vm.Box = "ubuntu/trusty64" if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil config.vm.synced_folder ".","/vagrant",mount_options: ["dmode=700,fmode=600"] # find out a way to move this to environment variables... # this is to speed up maven builds on vagrant Box by reusing host maven repository config.vm.synced_folder "c:\Users\woci\.m2\repository ","/home/vagrant/.m2/repository",fmode=600"] # to provIDe access to configuration config.vm.synced_folder "d:\data\dev\pro\pro-lab\pro-lab-config","/pro_config",fmode=600"] end # else # config.vm.synced_folder ".","/vagrant" # config.vm.synced_folder "c:\Users\woci\.m2\repository ","/extrepo" # end config.vm.provIDer "virtualBox" do |v| v.memory = 4096 end config.vm.define :dev do |dev| dev.vm.network "private_network",ip: "10.100.198.200" dev.vm.provision :shell,path: "bootstrap.sh" dev.vm.provision :shell,inline: 'PYTHONUNBUFFERED=1 ansible-playbook /vagrant/ansible/dev.yml -c local' end if Vagrant.has_plugin?("vagrant-cachIEr") config.cache.scope = :Box end end
泊坞窗,compose.yml
services: configserver: build: ./config-server image: pro-lab/config-server volumes: - /pro_config:/config ports: - "8888:8888" attachment-manager: build: ./attachment-manager image: pro-lab/attachment-manager ports: - "8080:8080" mongo: image: mongo ports: - "27017:27017" redis: image: redis ports: - "6379:6379" datadog: image: datadog/docker-dd-agent:latest environment: API_KEY: ... volumes: - /var/run/docker.sock:/var/run/docker.sock - /proc/:/host/proc/:ro - /sys/fs/cgroup/:/host/sys/fs/cgroup:ro - /vagrant/docker/dd-agent/conf/:/conf.d/:ro - /vagrant/:/vagrant/
总结以上是内存溢出为你收集整理的在Windows上通过Vagrant运行时,通过主机名访问docker容器全部内容,希望文章能够帮你解决在Windows上通过Vagrant运行时,通过主机名访问docker容器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)