doutuo3899 2016-11-28 03:04
浏览 101

无法让localhost连接到流浪汉中的docker

I'm trying to build a local dev environment for GoLang.

My environment would consist of a VirtualBox VM using ubuntu and inside I'd use docker-compose to build out my different pieces.

All other pieces of my environment work, except for golang.

When I attempt to get a simple hello world HTTP response it get back "ERR_SOCKET_NOT_CONNECTED" inside chrome.

My vagrant file looks like

Vagrant.configure("2") do |config|
  config.vm.box =  "ubuntu/trusty64"

  port = 3000
  config.vm.hostname = "vagrant-docker-example"
  config.vm.network(:forwarded_port, guest: port, host: port)
  config.vm.network(:forwarded_port, guest: 8080, host: 8080)
  config.vm.network(:forwarded_port, guest: 80, host: 4567)


  config.vm.provision :shell, inline: "apt-get update"
  config.vm.provision :docker
  config.vm.provision :docker_compose, env: { "PORT" => "#{port}" }, yml: ["/vagrant/docker-compose-base.yml","/vagrant/docker-compose.yml"], rebuild: true, project_name: "myproject", run: "always"
end

and my docker-compose file looks like

app:
  build: ./
  links:
    - redis
  ports:
    - "${PORT}:8080"

nginx:
    image: nginx:latest
    ports:
        - 80:80

finally my docker file looks like

# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang

# Copy the local package files to the container's workspace.
ADD . $GOPATH/src/github.com/sinangedik/vagrant-docker-go-example

#Build
RUN go get github.com/tools/godep &&\
    cd $GOPATH/src/github.com/sinangedik/vagrant-docker-go-example &&\
    godep go build

#Give the ownership to daemon
RUN ["chown", "-R", "daemon", "."]
USER daemon
#Set the port
ENV PORT 3000
# Document that the service listens on port 8080.
EXPOSE 3000
CMD ["/go/src/github.com/sinangedik/vagrant-docker-go-example/vagrant-docker-go-example"]

What am I doing wrong here?

the Vagrant call is being run inside windows 10.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度