Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

full nixos inside docker #3779

Merged
merged 3 commits into from Sep 1, 2014
Merged

full nixos inside docker #3779

merged 3 commits into from Sep 1, 2014

Conversation

offlinehacker
Copy link
Contributor

This is first attempt to run full nixos inside docker. You will need docker 1.2.0(already meged into master), because of support of adding capabilities to containers. Currenty it should not be possible to run these images on docker virtualization providers, because docker was, but does not have patch for systemd included anymore, because of (for my opinion) not so relevant non systemd related bugs(see: docker-archive/libcontainer#30 and moby/moby#3629).

  • To build docker base image use:
export NIXOS_CONFIG=$(pwd)/modules/virtualisation/docker-image.nix
nix-build . -A config.system.build.dockerImage
  • To import image to docker(docker daemon must be running):
cat result/tarball/nixos-system-x86_64-linux.tar.xz| sudo docker import - nixos
  • To start it:
sudo docker/bin/docker run -t -i --cap-add=SYS_ADMIN --cap-add=SYS_RESOURCE -e "container=docker" nixos /bin/init

As soon as docker will be patched to have cgroups mounted, i will make it run without these additional flags.

UPDATE: I still have to figure out how to push new base image to docker image repos

Sometimes extra arguments when making tarball are required,
for example if making a container owner of files has to be changed
to root.
@offlinehacker
Copy link
Contributor Author

You can try it here: https://registry.hub.docker.com/u/offlinehacker/nixos/

@lucabrunox
Copy link
Contributor

Works perfectly, even on ubuntu+nix by installing docker from nixpkgs master. I suggest to use /init instead of /bin/init to not have init in PATH.

@aristidb
Copy link
Contributor

+1, I think this would be a nice way for new people to try out NixOS as well.

7c6f434c added a commit that referenced this pull request Sep 1, 2014
@7c6f434c 7c6f434c merged commit d140851 into NixOS:master Sep 1, 2014
@offlinehacker
Copy link
Contributor Author

Can you please make console-getty optional based on boot.isContainer, or
some people might have trouble?
On Sep 1, 2014 11:04 PM, "Michael Raskin" notifications@github.com wrote:

Merged #3779 #3779.


Reply to this email directly or view it on GitHub
#3779 (comment).

@7c6f434c
Copy link
Member

7c6f434c commented Sep 1, 2014

Can you please make console-getty optional based on boot.isContainer, or

Is "enable = boot.isContainer;" enough?

@lucabrunox
Copy link
Contributor

enable = mkDefault config.boot.isContainer maybe

@offlinehacker
Copy link
Contributor Author

I think this should be enough, at least it Works for normal services.
On Sep 1, 2014 11:22 PM, "Michael Raskin" notifications@github.com wrote:

Can you please make console-getty optional based on boot.isContainer, or

Is "enable = boot.isContainer;" enough?


Reply to this email directly or view it on GitHub
#3779 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants