我在Windows 7上的Vagrant VM(VirtualBox)中运行docker。一切工作正常,我通过docker-compose成功设置了几个容器。 容器可以通过从docker-compose文件映射服务名称的逻辑主机名访问自己。
有没有什么办法可以通过这些逻辑主机名来访问容器,而不仅仅是容器本身,而且还来自:
通过这种方式,我不必为从顶层窗口主机和目标容器交互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", mount_options: ["dmode=700,fmode=600"] # to provide access to configuration config.vm.synced_folder "d:\\data\\dev\\pro\\pro-lab\\pro-lab-config", "/pro_config", mount_options: ["dmode=700,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/