Skip to content

kevvlvl/imageless-container-hello

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Creating an imageless container

A special thank you and credits for this example goes to Ivan Velichko and his blog: https://iximiuz.com/en/posts/you-dont-need-an-image-to-run-a-container/

Steps

  1. Generate an oci/config config file
    runc spec
  1. Create a Go file with a simple "Hello world" example. Make sure you have go installed at this point
  2. Setup the container's filesystem.
$ go mod init
$ GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o printme
$ file printme
> printme: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped

$ mkdir rootfs
$ mv printme rootfs/
  1. Change the config.json file
    • process.args = "/printme"
    • hostname = "imageless-hello"
    • process.terminal = false"
  2. Create the container
sudo runc create imageless-hello
  1. We can now list the container that is created
sudo runc list                 
ID                PID         STATUS      BUNDLE                                 CREATED                          OWNER
imageless-hello   0           created     /home/kev/go/src/imageless-container   2021-11-16T05:03:50.605474896Z   root
  1. Run the container
sudo runc start imageless-hello

At this point you should see that the OCI/container we ran outputted "Operating System Hostname imageless-hello"

  1. Now we can delete the container that is in stopped STATUS
sudo runc delete imageless-hello

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages