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

Add Dockerfile, which builds docker with nix package manager #4642

Closed
wants to merge 1 commit into from

Conversation

offlinehacker
Copy link
Contributor

With this Dockerfile, https://registry.hub.docker.com/u/offlinehacker/nixpkgs will automaticlly build docker image with nix package manager and nixpkgs(repo itself) on every push. To use this docker image: docker -t -i offlinehacker/nixpkgs. I advise nixos organization to create it's own account on docker registry and setup automated builds.

Example Dockefile that uses this image:

FROM offlinehacker/nixpkgs
RUN nix-env -iA nixpkgs.mongodb
RUN mkdir -p /var/db/mongodb
CMD mongod --dbpath /var/db/mongodb

PS: Docker is not a replacement for nixos, docker is process manager(which can also run whole nixos container), nixos is os, just to make this clear.

@garbas
Copy link
Member

garbas commented Oct 24, 2014

@offlinehacker you think you can create a NixOS account and manage it for now? i guess you're the biggest docker+nix user

@offlinehacker
Copy link
Contributor Author

I can create nixos docker account if others are fine with that(i can share login info)? @edolstra @rbvermaa @iElectric ?

@offlinehacker offlinehacker added this to the 14.11 milestone Oct 25, 2014
@rbvermaa
Copy link
Member

rbvermaa commented Nov 4, 2014

@offlinehacker I'm fine with you creating a nixos account if you keep the image up-to-date.

@rbvermaa
Copy link
Member

rbvermaa commented Nov 4, 2014

@offlinehacker Can we put the Dockerfile somewhere else than the root of nixpkgs?

@offlinehacker
Copy link
Contributor Author

@rbvermaa as far as i know yes, where do you think it should be put, maybe in top-level because it is nixpkgs related and not nixos?

keeping up-to-date is a matter of pushing a button on docker hub, and even this could be automated if a branch would be updated on unstable release, this would be really usefull.

@rbvermaa
Copy link
Member

rbvermaa commented Nov 4, 2014

@offlinehacker How about in maintainers/docker/ subdirectory?

@aristidb
Copy link
Contributor

aristidb commented Nov 8, 2014

Merged, in subdirectory

@aristidb aristidb closed this Nov 8, 2014
@offlinehacker
Copy link
Contributor Author

I will reopen this pull request, because this dockerfile needs some tunning, i'm working on kubernetes nixos module, so after extensive testing i will make required modifications and report back what's the best way of running nixpkgs/nixos on docker like clouds.

@offlinehacker offlinehacker reopened this Nov 16, 2014
@aristidb
Copy link
Contributor

Oh no, think about the "open pull request" count! ;-)

@domenkozar domenkozar removed this from the 14.11 milestone Nov 30, 2014
@domenkozar
Copy link
Member

Let me know if this should be part of 14.11 release

@7c6f434c
Copy link
Member

@offlinehacker So, are there any outstanding changes here?

I guess minor changes should be committed directly, and a PR without any changes should be closed. An issue could be created in its place, if needed.

FROM busybox

RUN dir=`mktemp -d` && trap 'rm -rf "$dir"' EXIT && \
wget -O- http://nixos.org/releases/nix/nix-1.7/nix-1.7-x86_64-linux.tar.bz2 | bzcat | tar x -C $dir && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be updated for Nix 1.8. Also, why not simply use the install procedure curl https://nixos.org/nix/install | sh?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's even proper way to run nix with docker, I'm working on
service abstraction layer that would make declarative docker containers
possible.
On Jan 23, 2015 11:53 PM, "Wout Mertens" [email protected] wrote:

In Dockerfile
#4642 (comment):

@@ -0,0 +1,12 @@
+FROM busybox
+
+RUN dir=mktemp -d && trap 'rm -rf "$dir"' EXIT && \

This needs to be updated for Nix 1.8. Also, why not simply use the install
procedure curl https://nixos.org/nix/install | sh?


Reply to this email directly or view it on GitHub
https://github.com/NixOS/nixpkgs/pull/4642/files#r23486704.

@offlinehacker
Copy link
Contributor Author

This is in nix now

@bbarker
Copy link
Contributor

bbarker commented Sep 1, 2017

Using a very simple Dockerfile, I get an error that seems to indicate /bin/sh does not exist.

FROM offlinehacker/nixos
COPY *.nix /etc/nixos/
RUN "nixos-rebuild switch --upgrade"
$ docker build -t nixos:testing0 -f NixOS .                                                                                                                                                                                                                                                                                                                                                                       
Sending build context to Docker daemon  14.34kB
Step 1/3 : FROM offlinehacker/nixos
 ---> 65f8b74f4779
Step 2/3 : COPY *.nix /etc/nixos/
 ---> 4543000ca04b
Removing intermediate container de86ee1dd67c
Step 3/3 : RUN "nixos-rebuild switch --upgrade"
 ---> Running in 671ac3ef975d
container_linux.go:262: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory"
oci runtime error: container_linux.go:262: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement Add something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants