我正在按照https://docs.docker.com/compose/django/上的说明来获得一个基本的停靠的django应用程序。我可以在本地运行它,没有问题,但我在使用Elastic Beanstalk将其部署到AWS时遇到了问题。在阅读了here之后,我认为我需要将docker-compose.yml转换成Dockerrun.aws.json才能正常工作。
原始docker-compose.yml是
version: '2'
services:
db:
image: postgres
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db这是我到目前为止翻译的内容
{
"AWSEBDockerrunVersion": 2,
"volumes": [
{
"name": "db"
},
{
"name": "web"
}
],
"containerDefinitions": [
{
"name": "db",
"image": "postgres",
"essential": true,
"memory": 256,
"mountPoints": [
{
"sourceVolume": "db"
"containerPath": "/var/app/current/db"
}
]
},
{
"name": "web",
"image": "web",
"essential": true,
"memory": 256,
"mountPoints": [
{
"sourceVolume": "web"
"containerPath": "/var/app/current/web"
}
],
"portMappings": [
{
"hostPort": 8000,
"containerPort": 8000
}
],
"links": [
"db"
],
"command": "python manage.py runserver 0.0.0.0:8000"
}
]
}但它不起作用。我做错了什么?
发布于 2017-04-10 06:28:04
我一直在努力了解Dockerrun格式的细节。查看Container Transform:"Transforms docker-compose,ECS,and Marathon configuration“...它是救命稻草。下面是它为您的示例输出的内容:
{
"containerDefinitions": [
{
"essential": true,
"image": "postgres",
"name": "db"
},
{
"command": [
"python",
"manage.py",
"runserver",
"0.0.0.0:8000"
],
"essential": true,
"mountPoints": [
{
"containerPath": "/code",
"sourceVolume": "_"
}
],
"name": "web",
"portMappings": [
{
"containerPort": 8000,
"hostPort": 8000
}
]
}
],
"family": "",
"volumes": [
{
"host": {
"sourcePath": "."
},
"name": "_"
}
]
}
Container web is missing required parameter "image".
Container web is missing required parameter "memory".
Container db is missing required parameter "memory".也就是说,在这种新格式中,您必须告诉它要为每个容器分配多少内存。此外,您还需要提供映像-没有构建选项。正如评论中提到的,您希望构建并推送到Dockerhub或ECR,然后给出它的位置:例如DockerHub上的[org name]/[repo]:latest,或者ECR的URL。但是container-transform为你做了mountPoints和volumes --太神奇了。
发布于 2016-09-13 12:22:01
你有一些问题。
1) 'web‘看起来不像是'image',你把它定义为'build’。在你的被告席上-作曲..记住,Dockerrun.aws.json必须从某个地方提取镜像(最简单的方法是使用ECS的存储库)
2)我认为“command”是一个数组。所以你会有:
"command": ["python" "manage.py" "runserver" "0.0.0.0:8000"]3)您的mountPoints是正确的,但顶部的音量定义错误。{ "name":"web","host":{ "sourcePath":"/var/app/current/db“}我不是百分之百确定,但路径适合我。如果您有Dockerrun.aws.json文件,则旁边是一个名为/db的目录。然后这将是挂载位置。
https://stackoverflow.com/questions/39460512
复制相似问题