使用本地主机

时间:2018-10-02 19:36:52

标签: docker

我最近在DigitalOcean上创建了一个Droplet,以便将我的本地开发文件部署在DigitalOcean上。我将运行docker-compose up,然后可以使用远程IP地址访问该站点。但是我无法使用localhost127.0.0.1访问它。我需要此本地访问权限,以便可以在没有互联网的情况下测试自己的开发。

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

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

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

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

有什么办法可以通过本地主机访问我的码头工人?

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

1 个答案:

答案 0 :(得分:0)

不,这不起作用。根据定义,在您的个人计算机上,“ Dim e Set e = ie.document.getElementsByClassName("here")(1) e.Click ”是指您的个人计算机,而不是液滴。此外,由于Digital Ocean液滴不属于您的计算机,因此您无法不使用Internet来访问其液滴。它们是Digital Ocean服务器的一部分,您需要互联网才能访问它们。