• Stars
    star
    283
  • Rank 146,066 (Top 3 %)
  • Language
    Nix
  • Created about 11 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Provision Docker images using Nix

nix-docker

Use NixOS configurations to provision Docker containers.

Read about the what and why in this blog post

DISCLAIMER: This project is no longer actively maintained and probably broken, if you're interested in fixing it, please fork and contact me: [email protected]

Installation with Vagrant

The easy way to do this is to use Vagrant.

When you have Vagrant installed:

git clone https://github.com/zefhemel/nix-docker.git
cd nix-docker
vagrant up
vagrant ssh

If all went well, you're now in a VM that has both Docker and Nix installed and nix-docker in its path.

At this point you need to connect to the VM and have nix setup the vagrant users own custom package stores. execute the follow

nix-channel --update
nix-env -i hello

You can now cd into the nix-docker/samples directory to try to build some of the examples. Note that the ~/nix-docker directory is mounted from your host machine, so you can edit your files with your favorite editor and have them available within the VM.

Installation

To use nix-docker you need Nix installed as well as Docker. Realistically, your best way to do this on an Ubuntu (12.04 or 13.04) box. Once these are installed, installing nix-docker is as simple as:

git clone https://github.com/zefhemel/nix-docker.git
nix-env -f nix-docker/default.nix -i nix-docker

Usage

To build a stand-alone Docker image:

nix-docker -b -t my-image configuration.nix

This will build the configuration specified in configuration.nix, have a look in the samples/ directory for examples. It will produce a docker image named my-image which you can then run anywhere. Use username/my-image to be able to push them to the Docker index.

To build a host-mounted package:

nix-docker -t my-image configuration.nix

This will produce a Nix package (symlinked in the current directory in result) containing a script you can use to spawn the container using Docker, e.g.:

sudo -E ./result/sbin/docker-run

to run the container in the foreground, or:

sudo -E ./result/sbin/docker-run -d

to daemonize it. What the docker-run script will do is check if there's already a docker image available with the current image name and tag based on the Nix build hash. If not, it will quickly build it first (these images take up barely any space on disk). Then, it will boot up the container.

Distributing host-mounted packages is done by first copying the Nix closure resulting from the build to the target machine (when you do the build it will give you example commands to run):

nix-copy-closure root@targetmachine /nix/store/....

Then, you can spawn the container remotely with the script path provided in the output of the build command.

More Repositories

1

matterless

Self-hosted serverless
Go
38
star
2

adia

A Clojure Web application framework
Clojure
30
star
3

docker-images

Useful images for docker
Shell
23
star
4

nixops-mac-setup

Script to easily setup Nix and NixOps for use on Mac
Shell
22
star
5

nodejs-nix

Basic node.js application and dev environment with Nix
JavaScript
13
star
6

argspecjs

A proper way to handle optional arguments in Javascript
JavaScript
12
star
7

zcms

A Zed-based CMS (used as a Zed package)
JavaScript
5
star
8

nixcloud

An conceptual general-purpose PaaS built on top of Nix
Python
4
star
9

cande

Javascript Canvas based IDE
JavaScript
3
star
10

ace-builds

ACE builds
JavaScript
3
star
11

mobl-plugin

Eclipse plug-in files for mobl
Shell
3
star
12

aws-serverless-dev

Docker container running various AWS serverless APIs
Makefile
2
star
13

mattermost-functions

Run functions in respond to eventbus events
Go
2
star
14

diesler

A dynamic language to build DSLs
Java
2
star
15

denorunner

Go
2
star
16

nuggetdb

A document database system on top of MySQL
Java
2
star
17

mobiworks

jQuery based framework for developing iPhone/Android web applications
JavaScript
2
star
18

matterless-mattermost-apps-examples

Example implementations of "Mattermost Apps" using Matterless
2
star
19

bracket-check

Language agnostic matching bracket syntax checker for Zed
JavaScript
2
star
20

gelly

A language to build DSLs in
2
star
21

fluttermost

An experiment in creating a Mattermost client in Flutter
Dart
2
star
22

clojs

Clojure to Javascript compiler
Clojure
2
star
23

sample-zed-package

Sample Zed package
JavaScript
1
star
24

testrepo

For Zed git stuff
JavaScript
1
star
25

SWebDSL

Scala WebDSL
Scala
1
star
26

zed-pep8

PEP8 support for Zed
JavaScript
1
star
27

fulltext

Fulltext project indexing for Zed
JavaScript
1
star
28

confplan

ConfPlan
1
star
29

matterless-studio

Browser-based IDE for Matterless
TypeScript
1
star
30

vfs-ssh

A vfs tunnel over an ssh connection.
JavaScript
1
star
31

jsfax

Javascript Spoofax toolkit for Javascript, with syntax file, pretty printers, optimizers etc.
JavaScript
1
star
32

follow-complete

Follow Complete experimental code completion for Zed
JavaScript
1
star
33

mattermost-matterless-plugin

Go
1
star
34

yamlschema

Go library to use JSON schemas written in YAML to validate YAML objects
Go
1
star
35

node-lpc

Local Procedure Calls for node.js
JavaScript
1
star