Skip to content

DUOLabs333/container

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

container: Containerization tool written in Python

To start, 
1. make folder ~/Containers, and move container into a place in your $PATH
2. Next, run "container init void"
3. Download a Void Linux rootfs and move it into ~/Containers/void/diff
4. Run "container init $CONTAINER" and edit the container-compose.py with the commands to start
5. Once you have prepared your image, run "container start $CONTAINER"

To build, run `mod`


====================Docs=======================
Containerfile:
This is where you list the steps to build the image.

container-compose.py:
This is where you list the steps to run the image.

$CONTAINERS_ROOT:
This is the directory where all containers will be in.

Colon-string:
$A:$B is equivalent to $CONTAINERS_ROOT/$A/diff/$B. If $A$=="root", this is just /$B. In this case, $B$ can be relative to the directory where the command was called from.

Functions (to be used in Containerfile and container-compose.py):

Ps(process) --- If $process is "main", get the PID of the script. If $process is "auxiliary", get the PIDs of all the processes under the chroot. This is mostly for internal use, and should only be used for debugging.

Mount(IN,OUT) --- mount directory on $IN, in $OUT. $IN is a colon-string. $OUT is an absolute path relative to the container.

Copy(IN,OUT) --- copy file/directory from $IN to $OUT. $IN is a colon-string. $OUT is an absolute path relative to the container.


Loop(func,delay) --- Run $func every delay seconds. If $func is a string, it will be treated as a shell command. Otherwise, it will be run as a Python function.

Wait(delay=None) --- if $delay==None, then wait forever, otherwise, wait for the indicated number of seconds

Layer(layer,mode="RO") --- add $layer as an layer to the container. $mode, which can either be 'RO' (for read-only) and 'RW' (for read-write), indicates how it should be mounted. All Layers must be specified at the top of the file.

Base(base) --- Set $base to be the base layer. This is not strictly neccessary (you can use Layer), but can be useful if some Layers have different Bases --- only the first Base specified will be used.

Workdir(work_dir) --- set $work_dir as working directory of container

Env(value) --- set $env as an environment variable(s) in container 

User(user) --- set $user as working user. Can either be just user or user:group. You can also pass in numbers for the user and group.

Shell(shell) --- set $shell as shell

Volume(name,path) --- Bind volume $name in the container's Volumes path to $path in container. $name can also refer to other containers with the colon-string syntax.

Port(_from,_to) --- bind port $_from in container to port $_to on host

Run(command="",pipe=False) --- Run $command in container. $pipe indicates whether output should be returned rather than being written to the log file

Note: If you are on Linux, you can enable user and net namespaces with CONTAINER_USER_NAMESPACES=1 and CONTAINER_NET_NAMESPACES=1, respectively (do be aware that net namespaces are slower than on the root ns)
If you do enable CONTAINER_USER_NAMESPACES, you can set up /etc/subuid and /etc/subgid if you want to be able to access other UIDs and GIDs.

Commands:
Start --- runs container-compose.py

Build --- runs Containerfile

Stop --- kills all processes in container

Restart --- stops, then starts the container

Chroot --- runs an interactive shell in the container. If --and-stop, after the chroot is stopped, the container will be stopped. --run=$command allows you to run a specific command without the TTY.

List --- list specified containers

Init --- make new container. Docker support is available if --pull is specified

Edit --- edit container-compose.py

Status --- list status of container ("Started" or "Stopped")

Log --- read log of container

Clean --- delete everything in the container's diff folder

Delete --- deletes the container

Watch --- incrementally show the container's log in the terminal

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages