azukiapp / azk

azk is a lightweight open source development environment orchestration tool. Instantly & safely run any environment on your local machine.
http://azk.io
Apache License 2.0
897 stars 63 forks source link

Running docker server inside azk #548

Open mauricioklein opened 8 years ago

mauricioklein commented 8 years ago

Is is possible to run (or access) a Docker server inside Azk?

My project require some specific containers to be started on runtime, but running inside Docker it seems that Docker server isn't accessible there.

Thanks in advance!

nuxlli commented 8 years ago

@mauricioklein now you can do this in two ways:


1 - dind mode: running a docker server inside a docker container (aka docker-in-docker):

// Azkfile.js
systems({
  dind: {
    image: "docker:1.9-dind",
    mounts: {
      "/var/lib/docker": persistent("dind-volumes"),
    },
    docker_extra: {
      HostConfig: { Privileged: true },
    },
    ports: {
      docker: "2375/tcp",
    },
    export_envs: {
      DOCKER_HOST: "tcp://#{net.host}:#{net.port.docker}"
    }
  },

  'dind-client': {
    depends: ["dind"],
    image: "docker:1.9",
  },
});

Now you can run:

$ azk start dind
$ azk shell dind-client

2 - socket mode: mount the docker socket host in a docker container and connect to it (requires integration of this PR #549):

// Azkfile.js
systems({
  docker: {
    image: "docker:1.9",
    mounts: {
      "/var/run/docker.sock": path("/var/run/docker.sock", { resolve: false }),
    }
  }
});

Now you can run:

$ azk shell docker

More info about this images: https://hub.docker.com/r/library/docker/