dockerhpc

Is there an enroot equivalent to docker run?


I have a simple container, that I've built with a Dockerfile. I am running on Ubuntu-20.04 with enroot-3.4.1-1 and Docker version 26.0.0.

My Dockerfile takes a simple executable (compiled from C) and prints out 'Hello World', i.e. :

# syntax=docker/dockerfile:1
FROM scratch
ADD hello /
CMD ["./hello"]

I can run this image :

root@head01:/home/user/Scratch# docker image ls
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello         latest    d08237299659   7 hours ago     872kB
.
.
.
root@head01:/home/user/Scratch# docker run hello
Hello World

I exported my docker image to a squashfs file via :

root@head01:~# mkdir dockerout
root@head01:~# docker export optimistic_almeida | tar -C dockerout -p -s --same-owner -xv    
root@head01:~# mksquashfs dockerout hello.sqsh

Now if I try to run this with enroot

root@head01:/home/user/Scratch# enroot start hello.sqsh
enroot-switchroot: failed to execute: /bin/sh: No such file or directory

Question :

  1. Is there an enroot equivalent to docker run that just executes the CMD form the Dockerfile? It seems like enroot wants an interactive session but I don't think I built in a shell for it.

Solution

  • There are several issues with this question. According to this SO answer and from the scratch docs, the scratch template is very bare bones. There is no shell, kernel or other useful things.

    I'd be better off to use the ubuntu image as my base. Here is my Dockerfile

    # syntax=docker/dockerfile:1
    FROM ubuntu
    ADD hello /
    CMD ["./hello"]
    

    Convert the docker image to a squashfs file :

    $ docker build --tag hello .
    $ docker ps -a.               # Get the name from the  NAMES column
    $ mkdir dockerout
    $ docker export optimistic_visvesvaraya | tar -C somedir  -p -s --same-owner -xv
    $ mksquashfs dockerout dockerout.sqsh
    

    There appears to NOT be an exact enroot command to emulate docker run, but that's ok. We can just pass the command at the command line, e.g.

    $ enroot start dockerout.sqsh /hello