How to translate docker-compose.yml to Dockerrun.aws.json for Django

I follow the instructions https://docs.docker.com/compose/django/ to get the basic django app for docker. I can run it locally without problems, but I had problems deploying it to AWS using Elastic Beanstalk. After reading here , I thought I needed to translate docker-compose.yml to Dockerrun.aws.json for it to work.

Original 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 

and that’s what I’ve translated so far

 { "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" } ] } 

but it does not work. What am I doing wrong?

+5
source share
2 answers

I tried my best to get the inputs and outputs of the Dockerrun format. Check out Container Transform : "Converting Docker, ECS, and Marathon Configurations" ... it's a life saver. Here is what it outputs for your example:

 { "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". 

That is, in this new format, you must indicate how much memory is allocated for each container. In addition, you need to provide an image - there is no possibility for assembly. As mentioned in the comments, you want to create and click on DockerHub or ECR, and then specify this location: for example [org name]/[repo]:latest on Dockerhub or URL for ECR. But container-transform for you mountPoints and volumes is awesome.

+5
source

You have a few issues.

1) "web" is not an "image", you define it as "build". "in your docker essay .. Remember that Dockerrun.aws.json will have to pull the image from somewhere (the easiest way is to use ECS repositories)

2) I think the β€œteam” is an array. So you will have:

 "command": ["python" "manage.py" "runserver" "0.0.0.0:8000"] 

3) your mount points are correct, but the definition of the volume at the top is incorrect. {"name": "web", "host": {"sourcePath": "/ var / app / current / db"} I'm not 100% sure, but the path works for me. if you have the Dockerrun.aws.json file, next to it is the / db directory .. then this will be the mount location.

+1
source

All Articles