首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用本地主机访问DigitalOcean Docker droplet

使用本地主机访问DigitalOcean Docker droplet
EN

Stack Overflow用户
提问于 2018-10-03 03:36:52
回答 1查看 844关注 0票数 1

为了在DigitalOcean上部署我的本地开发文件,我最近在DigitalOcean上创建了一个droplet。我将运行docker-compose up,并且我可以使用远程IP地址访问该站点。但我不能使用localhost127.0.0.1访问它。我需要这个本地访问,所以我可以测试我的发展没有互联网。

我使用digitalocean驱动程序创建了docker-machine,如下所示:

docker-machine create --driver digitalocean --digitalocean-access-token $DOTOKEN machine-name

这是我的docker-compose.yml文件:

代码语言:javascript
复制
data:
  extends:
    file: docker-compose-common.yml
    service: data

db:
  extends:
    file: docker-compose-common.yml
    service: db
  ports:
    # Publish the port so it's visible on the host, you can access the db directly
    - "3306:3306"
  environment:
    # Environment variables to configure MySQL on startup.
    # We don't care about commiting these creds to GitHub because they're only
    # for our local development environment
    - MYSQL_ROOT_PASSWORD=my-root-password-dev
    - MYSQL_DATABASE=guestbook-dev
    - MYSQL_USER=guestbook-admin
    - MYSQL_PASSWORD=my-guestbook-admin-password-dev
  volumes_from:
    # Mount the volumes from the data container to store our MySQL files
    - data

app:
  extends:
    file: docker-compose-common.yml
    service: app
  ports:
    # Publish the port so it's visible on the host, you can access the app directly
    - "8000:8000"
  links:
    # Link to the db service to store state
    - db:db
  volumes:
    # Mount the app dir in the container as /src so our changes to the app code
    # are also changed in the container
    - ./app:/src
  command: gunicorn --reload app:app --bind 0.0.0.0:8000
    # Run Gunicorn to serve app requests and reload on change so we can see our
    # changes to the app code


web:
  extends:
    file: docker-compose-common.yml
    service: web
  ports:
    # Publish the port so it's visible on the host
    - "80:80"
  links:
    # Link to the app to serve requests
    - app:app

有没有办法用localhost访问我的docker?

PS:我正在使用Mac作为我的开发平台

EN

回答 1

Stack Overflow用户

发布于 2018-10-03 03:44:36

不,这行不通的。在您的个人计算机上,根据定义,"localhost“指的是您的个人计算机,而不是水滴。此外,如果不使用互联网,你就无法访问你的水滴,因为数字海洋水滴不是你计算机的一部分;它们是数字海洋服务器的一部分,你需要互联网来访问它们。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52615236

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档