Jump to content

Docker: Difference between revisions

164 bytes added ,  15 June 2023
mention running docker containers with virtualisation.oci-containers - still missing further docs though :)
imported>Kadimisetty
imported>Raboof
(mention running docker containers with virtualisation.oci-containers - still missing further docs though :))
Line 1: Line 1:
[https://docker.com Docker] is a utility to pack, ship and run any application as a lightweight container.  
[https://docker.com Docker] is a utility to pack, ship and run any application as a lightweight container.  
= Docker on NixOS =


== Installation ==
== Installation ==
Line 43: Line 45:


The <code>setSocketVariable</code> option sets the <code>DOCKER_HOST</code> variable to the rootless Docker instance for normal users by default.
The <code>setSocketVariable</code> option sets the <code>DOCKER_HOST</code> variable to the rootless Docker instance for normal users by default.
== docker images as systemd services ==
To make sure some docker images are running as systemd services, you can use 'oci-containers':
<syntaxHighlight lang=nix>
virtualisation.oci-containers.containers = [
  ...
];
</syntaxHighlight>
=  Creating images =


== Building a docker image with nixpkgs ==
== Building a docker image with nixpkgs ==
Line 147: Line 161:
</syntaxHighlight>
</syntaxHighlight>


== Using Nix in containers ==
= Using Nix in containers =


While [https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-dockerTools dockerTools] allows to build lightweight containers, it requires <code>nix</code> to be installed on the host system. An alternative are docker images with nix preinstalled:
While [https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-dockerTools dockerTools] allows to build lightweight containers, it requires <code>nix</code> to be installed on the host system. An alternative are docker images with nix preinstalled:
Line 154: Line 168:
* [https://hub.docker.com/r/nixpkgs/nix nixpkgs/nix] (built from https://github.com/nix-community/docker-nixpkgs)
* [https://hub.docker.com/r/nixpkgs/nix nixpkgs/nix] (built from https://github.com/nix-community/docker-nixpkgs)


== See also ==
= See also =


[[Workgroup:Container]]
[[Workgroup:Container]]


As of 22.05 [https://search.nixos.org/options?query=virtualisation.docker.rootless rootless] docker is available. Alternatively you can use [https://nixos.wiki/wiki/Podman Podman].
Alternatively you can use [https://nixos.wiki/wiki/Podman Podman].


[[Category:Cookbook]]
[[Category:Cookbook]]
Anonymous user