[英]AWS ElasticBeanstalk Multi-Container Rails/Nginx/Postgres: Invalid port number: “tcp://172.17.0.2:5432”
I am trying to deploy a multi-container docker rails/postgres/nginx app on Amazon ElasticBeanstalk (I have tried to move the postgres container to Amazon RDS but the relevant security group isn't being exposed - cause for another post). 我正在尝试在Amazon ElasticBeanstalk上部署多容器docker rails / postgres / nginx应用程序(我曾尝试将postgres容器移至Amazon RDS,但相关安全组未公开-导致另一篇帖子)。 Whenever I try to go the URL for the environment for my application I get: 每当我尝试访问应用程序环境的URL时,都会得到:
Invalid port number: "tcp://172.17.0.2:5432" 无效的端口号:“ tcp://172.17.0.2:5432”
I believe I am following all of the steps for building, tagging, and pushing the images, zipping up the source bundle, configuring the Dockerrun.aws.json properly, and updating and deploying the app to the environment. 我相信我将遵循所有步骤来构建,标记和推送图像,压缩源包,正确配置Dockerrun.aws.json以及将应用程序更新和部署到环境中。 I hope I've included all of the relevant files and tracing information below. 希望我在下面包括了所有相关文件和跟踪信息。 Any insight would be most appreciated. 任何见解将不胜感激。 Thank you. 谢谢。
Dockerrun.aws.json: Dockerrun.aws.json:
{
"AWSEBDockerrunVersion": 2,
"containerDefinitions": [
{
"name": "app",
"image": "830894003218.dkr.ecr.us-east-1.amazonaws.com/fusionrepo:app",
"essential": true,
"mountPoints": [
{
"containerPath": "/app",
"sourceVolume": "_"
}
],
"portMappings": [
{
"containerPort": 3000,
"hostPort": 3000
}
],
"workingDirectory": "/app",
"links": ["db"],
"memory": 128
},
{
"name": "db",
"essential": true,
"image": "postgres:10.3-alpine",
"mountPoints": [
{
"containerPath": "/var/lib/postgresql/data",
"sourceVolume": "postgres"
}
],
"portMappings": [
{
"containerPort": 5432,
"hostPort": 5432
}
],
"memory": 128
},
{
"name": "web",
"essential": true,
"memory": 128,
"image": "830894003218.dkr.ecr.us-east-1.amazonaws.com/fusionrepo:web",
"mountPoints": [
{
"containerPath": "/var/log/containers/nginx",
"sourceVolume": "_"
}
],
"portMappings": [
{
"containerPort": 80,
"hostPort": 80
}
],
"workingDirectory": "/app",
"links": ["app"],
"memory": 128
}
],
"family": "",
"volumes": [
{
"host": {
"sourcePath": "/var/app/current"
},
"name": "_"
},
{
"host": {
"sourcePath": "postgres"
},
"name": "postgres"
}
]
} }
docker-compose.yml 泊坞窗,compose.yml
version: '3'
volumes:
postgres: {}
services:
app:
build:
context: .
dockerfile: ./.docker/app/Dockerfile
depends_on:
- db
env_file:
- '.env'
ports:
- '3000:3000'
volumes:
- ./:/app
working_dir: /app
web:
build:
context: .
dockerfile: ./.docker/web/Dockerfile
depends_on:
- app
ports:
- 80:80
volumes:
- ./:/app
working_dir: /app
db:
image: 'postgres:10.3-alpine'
volumes:
- 'postgres:/var/lib/postgresql/data'
env_file:
- '.env'
config/database.yml 配置/ database.yml的
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
host: <%= ENV["DB_HOST"] %>
username: <%= ENV["DB_USERNAME"] %>
password: <%= ENV["DB_PASSWORD"] %>
port: <%= ENV.fetch("DB_PORT") { 5432 } %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: fusion_development
test:
<<: *default
database: fusion_test
production:
<<: *default
database: <%= ENV["DB_NAME"] %>
host: <%= ENV["DB_HOST"] %>
port: <%= ENV["DB_PORT"] %>
username: <%= ENV["PRODUCTION_DB_USERNAME"] %>
password: <%= ENV["PRODUCTION_DB_PASSWORD"] %>
# host: <%= ENV["RDS_HOSTNAME"] %>
# port: <%= ENV["RDS_PORT"] %>
# username: <%= ENV["RDS_USERNAME"] %>
# password: <%= ENV["RDS_PASSWORD"] %>
# host: <%= ENV["PRODUCTION_DB_HOST"] %>
# username: <%= ENV["PRODUCTION_DB_USERNAME"] %>
# password: <%= ENV['PRODUCTION_DB_PASSWORD'] %>
docker inspection 码头检查
sudo docker network inspect 2ab590882560
[
{
"Name": "bridge",
"Id": "2ab59088256063f635211f511f9cd6377a9963d832390e3ed3bfebc68f17679a",
"Created": "2018-07-31T02:07:23.005934521Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"103191687fa846d4cca480ca8f367328a2e7c23a75fe995318fa8f3b7ce5b7c4": {
"Name": "ecs-awseb-Fusion-Production-env-gvqsmaunxx-31-app-8eabdd9ca78198e71c00",
"EndpointID": "2b4292f1506a3aa403fd32b35b09d09a65137849a7beabc679289eac1c982fd3",
"MacAddress": "02:42:ac:11:00:03",
"IPv4Address": "172.17.0.3/16",
"IPv6Address": ""
},
"41477049948bb60ffcdec4ba13af7fcf83d81d1cfe4f3cfc471614acb7cb77de": {
"Name": "ecs-awseb-Fusion-Production-env-gvqsmaunxx-31-db-d682cfb7f3de89e69601",
"EndpointID": "72c68e7a5865f42adbabea98a65c1945d415fd5892baaed1d73b6ad34b8f8726",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
},
"f6924fab885c162fd21314df2779b55cbd26e67248283773b62d561f26c16566": {
"Name": "ecs-awseb-Fusion-Production-env-gvqsmaunxx-31-web-aea3eee3f891a8b63100",
"EndpointID": "39a9915179b956bc182c1e0be42d8299255493c0738a154df8b389362d7cc320",
"MacAddress": "02:42:ac:11:00:04",
"IPv4Address": "172.17.0.4/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
My first suggestion would be that using normal docker-compose logic, then DB_HOST wouldn't need to be configured as the "app" container would be auto-wired with a link to the "db" container using the "db" hostname. 我的第一个建议是,使用常规的docker-compose逻辑,则无需配置DB_HOST,因为将使用“ db”主机名将“ app”容器自动链接到“ db”容器的链接。
So your db YAML would look more like: ... production: <<: *default database: <%= ENV["DB_NAME"] %> host: db port: 5432 ...
因此,您的数据库YAML看起来更像是: ... production: <<: *default database: <%= ENV["DB_NAME"] %> host: db port: 5432 ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.