dockerTools.buildImage and user-writable /tmp

If you want custom file attributes, another option is to use the extraCommands parameter like this:

 theImage = dockerTools.buildImage {
    name = "foo";
    tag = "latest";
    created = "now";

    extraCommands = "mkdir -m 0777 tmp";

    contents = [thePkg
                xvfb_run
                bash
                coreutils
               ];

    config = {
      Cmd = ["/bin/xvfb-run" "-d" "/bin/foo"];
      WorkingDir = "/bin";
      User = "1000:1000";
      ExposedPorts = {
        "3000" = {};
        "4444-4473" = {};
      };
    };
  };

EDIT: note that the file is tmp and not /tmp. All the files relative to the current folder will later be packed into the image.

5 Likes