Docker http:// localhost:8000它不起作用

时间:2020-05-21 11:04:29

标签: docker docker-compose

我是Docker的新手,并试图在Docker中安装WordPress

Details are : 
OS : Windows 10 Home
Docker Version : Docker version 19.03.1, build 74b1e89e8a
docker-compose version 1.24.1, build 4667896b

我完成了以下步骤

version: '3.3'
  services:
  db:
    image: mysql:5.7
  volumes:
    - db_data:/var/lib/mysql
  restart: always
  environment:
    MYSQL_ROOT_PASSWORD: root
    MYSQL_DATABASE: mysql
    MYSQL_USER: admin
    MYSQL_PASSWORD: admin
  wordpress:
    depends_on:
      - db
  image: wordpress:latest
  ports:
    - "8000:80"
  restart: always
  environment:
    WORDPRESS_DB_HOST: db:3306
    WORDPRESS_DB_USER: admin
    WORDPRESS_DB_PASSWORD: admin
    WORDPRESS_DB_NAME: admin
  volume:
    db_data: {}

一切正常

$ docker ps                                                                                                                                            CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
944e0ea8ff69        wordpress:latest    "docker-entrypoint.s…"   34 minutes ago      Up 34 minutes       0.0.0.0:8000->80/tcp   wordpress_wordpress_1
5a3890fed7fe        redis               "docker-entrypoint.s…"   45 minutes ago      Up 45 minutes       6379/tcp               sleepy_matsumoto
4edf3f9fc944        mysql:5.7           "docker-entrypoint.s…"   About an hour ago   Up 38 minutes       3306/tcp, 33060/tcp    wordpress_db_1

但是当我在浏览器中运行http://localhost:8000http://localhost:80时,表明网站无法访问。我该如何解决?

1 个答案:

答案 0 :(得分:0)

我对这个问题有一个详细的答案,如下所示,因为我已经使用Docker Toolbox安装了Docker

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v19.03.5

现在可以了

http://192.168.99.100:8000/

现在终于可以了。希望它也会对您有帮助