我正在尝试将docker-compose up -d
投放到关注docker-compose.yml
文件
version: '2'
services:
php7-cli:
build: php7-cli
image: php7-cli
tty: true
volumes:
- ../:/var/www/app
networks:
- my-network
networks:
my-network:
driver: bridge
docker-compose build
已成功构建,但如果我尝试docker-compose up
,则会收到以下错误消息:
ERROR: could not find an available, non-overlapping IPv4 address
pool among the defaults to assign to the network
当我尝试docker network ls
时,我得到了
NETWORK ID NAME DRIVER SCOPE
7c8a6c131c1b bridge bridge local
9f16d3a33b4e host host local
24c54a4323ed none null local
我试图通过docker network prune
移除孤儿网络,但这些网络已被移除。
然后我尝试手动删除bridge
网络docker network rm 7c8a6c131c1b
但是我收到了这个错误
Error response from daemon: bridge is a pre-defined network and cannot be removed
这是我的docker version
docker version
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:17:20 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:15:30 2018
OS/Arch: linux/amd64
Experimental: false
答案 0 :(得分:1)
将网络接口从ens33重命名为eth0后,同样的问题消失了。 使用的一个指南是https://www.itzgeek.com/how-tos/mini-howtos/change-default-network-name-ens33-to-old-eth0-on-ubuntu-16-04.html
答案 1 :(得分:0)
尝试ifconfig
如果网络接口太多,则您可能之前无法正确停止docker。当您的计算机达到其最大网络接口数时,在这种情况下无法启动docker-compose(docker-compose up
无法创建新网络)。
以docker-compose
为例。
每次运行docker-compose up
时,我们都会创建一个网络接口,并且在运行docker-compose down
时应删除该接口。 docker-compose down
停止容器,并删除由up
创建的容器,网络,卷和映像。
答案 2 :(得分:0)
您必须删除您不使用的 bridge
网络!!!
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
070b2051c2d6 altacv_default bridge local
90269e56ef9c arquitecture_default bridge local
f04c85b27605 awesome-cv-docker_default bridge local
cfdc24506a32 aws-s3-bucket-state_default bridge local
51b7b53697cc bridge bridge local
e4f4800f11bf certs-resource_default bridge local
7d760fc8a8c3 cloner_default bridge local
4a161fb223cc coverletter_default bridge local
d16029047f65 distance-matrix-service_default bridge local
9e944ddd5da0 docker-compose-deployer_default bridge local
fb25db546e14 docker-compose-deployment_default bridge local
150cd02ad55c docker-neo4j_default bridge local
c76d6167e7b1 docker-pycobertura_default bridge local
$ docker network rm 655b6657b925 644fecac3549 6fac6fd59fe8 3d03a7df183d 40d112093fc7 32de1ea6549d 5cdd12695a4d 1e30562c7f63 58b1f6343780 e7bbf7af6dbb 4a161fb223cc 070b2051c2d6 90269e56ef9c
655b6657b925
Error response from daemon: error while removing network: network tools_supercash-data id 644fecac3549735341a482ddf330918a2050bc6ee2bcd4123d208051c836f9eb has active endpoints
6fac6fd59fe8
3d03a7df183d
40d112093fc7
...
...
...
docker-compose up
...
...