Docker容器在本地不可用

时间:2018-04-03 17:18:13

标签: docker docker-compose

使用docker-compose up -d创建容器后,容器已启动并正在运行,但它们在本地网络(127.0.0.1)中不可用。

我在另一台PC上使用相同的项目并且仍在工作..所以docker-compose.yml是相同的,它正在工作。

~ → docker info
Containers: 6
 Running: 1
 Paused: 0
 Stopped: 5
Images: 19
Server Version: 18.03.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfd04396dc68220d1cecbe686a6cc3aa5ce3667c
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.14.31-1-MANJARO
Operating System: Manjaro Linux
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 15.67GiB
Name: phantom
ID: JO4V:TAN5:64SP:5VRL:RUOQ:ZRTX:SUGL:T5NF:IXB7:YHS6:2CA6:3HCT
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

检查网卡似乎已正确设置

  ~ → ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 2c:fd:a1:73:7e:38 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.120/24 brd 192.168.1.255 scope global dynamic noprefixroute enp6s0
       valid_lft 80202sec preferred_lft 80202sec
3: br-0e93106ef232: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:74:c6:77:24 brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 brd 172.18.255.255 scope global br-0e93106ef232
       valid_lft forever preferred_lft forever
4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:40:ad:aa:5b brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
74: veth73892ae@if73: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
    link/ether ce:fd:5c:af:d2:06 brd ff:ff:ff:ff:ff:ff link-netnsid 0

看看iptable规则,似乎什么都没有阻止与容器的连接。

注意:为了确保它没有造成任何冲突,我禁用了IPv6,但没有任何改变。

这里是docker-compose.yml文件:

version: "3.1"
services:

    redis:
        image: redis:alpine
        container_name: proj-redis

    rabbitmq:
        image: rabbitmq:alpine
        container_name: proj-rabbitmq

    mysql:
      image: mysql:8.0
      container_name: proj-mysql
      working_dir: /application
      environment:
        - MYSQL_ROOT_PASSWORD=root
        - MYSQL_DATABASE=database
        - MYSQL_USER=database
        - MYSQL_PASSWORD=database

    webserver:
      image: nginx:alpine
      container_name: proj-webserver
      working_dir: /application
      volumes:
          - ./htdoc:/application
          - ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
      ports:
       - "80:80"
       - "9003:9003" # xDebug
       - "15672:15672" # RabbitMQ
      links:
       - php-fpm

    php-fpm:
      build:
        context: .
        dockerfile: phpdocker/php-fpm/Dockerfile
      container_name: proj-php-fpm
      working_dir: /application
      environment:
        XDEBUG_CONFIG: "remote_host=172.21.0.1"
        PHP_IDE_CONFIG: "serverName=dev.local"
      volumes:
        - ./htdoc:/application
        - ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.0/fpm/conf.d/99-overrides.ini

      links:
        - mysql
        - rabbitmq

0 个答案:

没有答案