0
votes

My Dockerrun.aws.json looks like this:

{
    "AWSEBDockerrunVersion": 2,
    "volumes": [
        {
            "name": "docker-socket",
            "host": {
                "sourcePath": "/var/run/docker.sock"
            }
        }
    ],
    "containerDefinitions": [
        {
            "name": "nginx",
            "image": "nginx",
            "environment": [
                {
                    "name": "VIRTUAL_HOST",
                    "value": "demo.local"
                }
            ],
            "essential": true,
            "memory": 128
        },
        {
            "name": "nginx-proxy",
            "image": "jwilder/nginx-proxy",
            "essential": true,
            "memory": 128,
            "portMappings": [
                {
                    "hostPort": 80,
                    "containerPort": 80
                }
            ],
            "mountPoints": [
                {
                    "sourceVolume": "docker-socket",
                    "containerPath": "/tmp/docker.sock",
                    "readOnly": true
                }
            ]
        }
    ]
}

Running this locally using "eb local run" results in:

ERROR: you need to share your Docker host socket with a volume at /tmp/docker.sock Typically you should run your jwilder/nginx-proxy with: -v /var/run/docker.sock:/tmp/docker.sock:ro See the documentation at http://git.io/vZaGJ

If I ssh into my docker machine and run:

docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy

It creates the container and mounts the volumes correctly.

Why is the above Dockerrun.aws.json configuration not mounting the /var/run/docker.sock:/tmp/docker.sock volume correctly?

If I run the same configuration from a docker-compose.yml, it works fine locally. However, I want to deploy this same configuration to Elastic Beanstalk using a Dockerrun.aws.json:

version: '2'
services:

  nginx:
    image: nginx
    container_name: nginx
    cpu_shares: 100
    volumes:
      - /var/www/html
    environment:
      - VIRTUAL_HOST=demo.local

  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    cpu_shares: 100
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro

My local setup is using:

  • VirtualBox 5.0.22 r108108
  • docker-machine version 0.7.0, build a650a40
  • EB CLI 3.7.7 (Python 2.7.1)
1
Side question: you are still using virtualbox and docker machine?OneCricketeer
I was when I posted this question, now using Kitematic / Docker for Mac. The problem persists..StuR

1 Answers

1
votes

Your Dockerrun.aws.json file works fine in AWS EB for me (only changed it slightly to use our own container / hostname in place of the 'nginx' container). Is it just a problem with the 'eb local run' setup, perhaps?

As you said are on Mac, try upgrading to the new docker 1.12 that runs docker natively on osx, or at least a newer version of docker-machine - https://docs.docker.com/machine/install-machine/#/installing-machine-directly