Pawel Furmaniak
Pawel Furmaniak

Reputation: 4806

Docker in docker on AWS Elastic Beanstalk

I have a docker container running on elastic beanstalk. From within this container I want to run other containers using the docker daemon running on the host OS.

As I read here http://blog.docker.com/category/demos/, it is possible if the first container is invoked by:

docker run -it -v /var/run/docker.sock:/var/run/docker.sock <image_name>

Can I make Beanstalk invoke my container is such way?

Upvotes: 1

Views: 633

Answers (2)

aldrinleal
aldrinleal

Reputation: 3609

Yes, its possible, but YMMV. Here's a rundown:

Dockerrun.aws.json allows you to map arbitrary paths into your container path. So, you can map your hosts's /var/run (which contains docker.sock) into a temp path. Here are the steps:

Make sure you've got a staging directory

In your dockerfile:

RUN mkdir /run-data

Make sure Dockerrun.aws.json contains it:

{
    "AWSEBDockerrunVersion": "1",
    "Logging": "/app/log",
    "Volumes": [
        {
            "HostDirectory": "/var/run",
            "ContainerDirectory": "/run-data"
        }
    ]
}

Then, the /run-data/docker.sock will contain a suitable docker socket for running commands. From this point, you can refer to the docker api and talk to it directly

Happy docking!

Upvotes: 2

Matteo Pacini
Matteo Pacini

Reputation: 22846

Unfortunately, Amazon Elastic Beanstalk adopts the policy "one container per VM", which is fairly limiting.

There might be a workaround, but it will be a waste of time.

You shoud use Amazon EC2 if you need to do that.

You can set up a new instance running Docker in less than 5 minutes!

Upvotes: 0

Related Questions