我在docker-compose.yml
之后使用容器:rc_db
,rc_queue
,rc_ui
,rc_service
; rc_ui
取决于rc_db
和rc_queue
; rc_service
取决于rc_queue
。它们全部位于rc-network
中。
我已验证rc_db
和rc_queue
位于rc-network
中,但是rc_ui
和rc_service
仍未附加@@。
似乎没有达到网络限制(即1024个容器?),所以我不知道为什么。
docker-compose.yml
version: '3'
services:
rc_db:
container_name: rc_db
image: mongo:3-stretch
restart: on-failure
environment:
- MONGO_INITDB_ROOT_USERNAME='root'
- MONGO_INITDB_ROOT_PASSWORD='1234@5678'
command: --config /etc/mongo/mongod.conf
volumes:
- mongodbdatatest:/data/db
- ./data/rc-db/logs:/logs
- ./data/rc-db/mongod.conf:/etc/mongo/mongod.conf
ports:
- 27017
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "10"
networks:
- rc-network
rc_queue:
container_name: rc_queue
image: rabbitmq:3.7.8-management
restart: on-failure
tty: true
volumes:
- rabbitdatatest:/var/lib/rabbitmq
- ./data/rc-queue/logs:/var/log/rabbitmq
- ./data/rc-queue/config:/etc/rabbitmq
environment:
- RABBITMQ_DEFAULT_USER='guest'
- RABBITMQ_DEFAULT_PASS='guest'
- RABBITMQ_HIPE_COMPILE=0
- RABBITMQ_LOGS='-'
- RABBITMQ_SASL_LOGS='-'
expose:
- 15671
- 15672
- 5672
ports:
- 15672
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "10"
networks:
- rc-network
rc_ui:
container_name: rc_ui
build:
context: .
dockerfile: ./rc-ui.Dockerfile
image: rc-ui
restart: on-failure
ports:
- 3005:3000
- 3006:8080
logging:
driver: "json-file"
options:
max-size: "30m"
max-file: "100"
environment:
- MONGO_HOST='rc_db'
- MONGO_PORT=27017
- MONGO_ROOT_USERNAME='root'
- MONGO_ROOT_PASSWORD='1234@5678'
- AMQP_ADDRESS='rc_queue'
volumes:
- ./data/rc-ui/data:/data
- ./data/rc-ui/logs:/app/logs
depends_on:
- rc_queue
- rc_db
networks:
- rc-network
rc_service:
container_name: rc_service
build:
context: .
dockerfile: ./rc-service.Dockerfile
image: rc-service
restart: on-failure
volumes:
- ./data/rc-service/config.json:/app/config.json
ports:
- 3001
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "10"
depends_on:
- rc_queue
networks:
- rc-network
environment:
- AMQP_ADDRESS='rc_queue'
volumes:
mongodbdatatest:
rabbitdatatest:
mongodbdata:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: './data/rc-db/db'
rabbitdata:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: './data/rc-queue/data'
networks:
rc-network:
driver: bridge
docker网络检查结果:
[
{
"Name": "rc-builder_rc-network",
"Id": "d7b327e45b54096c486a12147e83f546011c09f3ccbf155e30cf60834572ecbd",
"Created": "2018-10-13T10:34:36.0643726Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.23.0.0/16",
"Gateway": "172.23.0.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"1fd09274dcd3a53b4c584d98515297852682af73493bf33dac4872058ada12de": {
"Name": "rc_db",
"EndpointID": "b07dff5246c5a62a2c6530247d8772d55b4ce7c733b2456bd99433bd77d9089c",
"MacAddress": "02:41:ac:16:00:02",
"IPv4Address": "172.23.0.2/16",
"IPv6Address": ""
},
"850dee45e022ec1d5d4962614c48fe0635321835e1cc7a03225c1e79330c60bf": {
"Name": "rc_queue",
"EndpointID": "bfc81cbc83f701d350cfafdc6e2e055b967b40198a78d834c8085e606725e9c1",
"MacAddress": "02:41:ac:16:00:03",
"IPv4Address": "172.23.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "rc-network",
"com.docker.compose.project": "rc-builder",
"com.docker.compose.version": "1.22.0"
}
}
]
docker系统信息:
Containers: 5
Running: 2
Paused: 0
Stopped: 3
Images: 81
Server Version: 18.06.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
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: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.93-linuxkit-aufs
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 2.423GiB
Name: linuxkit-00155d23e106
ID: HXSI:X5B6:673K:P4ZO:FUIM:RNAC:FXHK:UUCP:KDRE:S3YJ:L7Y4:FK2R
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 39
Goroutines: 67
System Time: 2018-10-13T10:42:48.0039887Z
EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
答案 0 :(得分:0)
这与启动顺序无关。我认为设置环境变量的方式是错误的:
他们不应该是:
public function index()
{
return view('adduser');
}
public function create_user(Request $request)
{
return User::create(['input' => '$request->input']);
}
但是((没有environment:
- MONGO_HOST='rc_db'
- MONGO_PORT=27017
- MONGO_ROOT_USERNAME='root'
- MONGO_ROOT_PASSWORD='1234@5678'
- AMQP_ADDRESS='rc_queue'
,AMQP_ADDRESS在代码中使用URL地址,因此总是'
错误):
no route to host