Smith 是 Oracle 发布的一个
微容器构建工具
,使用 Golang 
开发。可以通过yum仓库和(可选)RPM文件来构建微容器。另外,它还可以“微化(micro-ize)”已有的Docker容器,在开发阶段,开发人员能够使用非常友好的Docker工具来构建容器,而在生产部署的时候,Smith能够将这个容器转换为微容器。Smith按照标准OCI格式来构建镜像,但是它也可以通过Docker仓库上传和下载镜像。
from http://studygolang.com/p/smith
-------------
Smith: A microcontainer builder
What is 
Building 
Building can be done via the Makefile:
Installing 
Installing can be done via the Makefile:
Using 
To use smith, simply create a smith.yaml defining your container and run
If you are building the same container multiple times without editing the package line, the
Smith can also build directly from oci files downloaded via the download command, or an oci directly from a docker repository. Simply specify either in your smith.yaml as package, for example:
from http://studygolang.com/p/smith
-------------
Smith: A microcontainer builder
What is smith?
smith is a simple command line utility for building
microcontainers
from rpm packages or oci images.Principles of microcontainers
- 
A microcontainer only contains the process to be run and its direct
dependencies.
 
- 
The microcontainer has files with no user ownership or special permissions
beyond the executable bit.
 
- 
The root filesystem of the container should be able to run read-only. All
writes from the container should be into a directory called /write. Any unique config that an individual container instance will need should be placed into a directory called/read. Ephemeral files such as pid files can be written to/run.
 
Building smith
Building can be done via the Makefile:make
golang-bin
Runtime dependencies
To build from rpms, smith requires:mock
sudo apt-get install createrepo yum
# At the time of this writing the below package is suitable and available
# for download. Your milage may vary and we suggest finding an official
# debian mock package that is 1.2 or 1.3.
wget http://ftp.debian.org/debian/pool/main/m/mock/mock_1.3.2-1_all.deb
sudo dpkg -i mock_1.3.2-1_all.deb
usermod -a -G mock <your_username>
# rpm on debian has a patch to macros that messes up mock so undo it. Note
# that updating your os will sometimes reset this file and you will have
# to run this command again.
sudo sed -i 's;%_dbpath\t.*;%_dbpath\t\t%{_var}/lib/rpm;g' /usr/lib/rpm/macros
# on debian/ubuntu for some reason yum tries to install packages for
# multiple archs, so it is necessary to update the yum.conf section in
# default.cfg to prevent that. If you switch your default.cfg you may
# have to do this again.
sudo sed -i '/\[main\]/a multilib_policy=best' /etc/mock/default.cfg
Installing smith
Installing can be done via the Makefile:sudo make install
Using smith
To use smith, simply create a smith.yaml defining your container and run
smith. If you want to overlay additional files or symlinks, simply place them
into a directory called rootfs beside smith.yaml.If you are building the same container multiple times without editing the package line, the
-f parameter will rebuild the container without
reinstalling the package.Build
To build a container with smith, create a smith.yaml file and invoke smith with no parameters:mkdir cat
cd cat
cat >smith.yaml <<EOF
package: coreutils
paths:
- /usr/bin/cat
cmd:
- /usr/bin/cat
- /read/data
EOF
mkdir -p rootfs/read
echo "Hello World!" >rootfs/read/data
smith
smith -i cat.tar.gz
smith --help
Build Types
Smith can build from local rpm files or repositories. You can change the yum config by modifying your /etc/mock/default.cfg.Smith can also build directly from oci files downloaded via the download command, or an oci directly from a docker repository. Simply specify either in your smith.yaml as package, for example:
package: https://registry-1.docker.io/library/fedora
paths:
- /usr/bin/cat
cmd:
- /usr/bin/cat
- /read/data
Advanced Usage
For more detailed instructions on building containers, check out How To Build a Tiny Httpd ContainerUpload
You can upload your image to a docker repository:smith upload -r https://username:password@registry-1.docker.io/myrepo/cat -i cat.tar.gz
latest. You can specify an alternative tag
name to use appending it after a colon:smith upload -r https://registry-1.docker.io/myrepo/cat:newtag
smith upload -d -r https://myregistry.com/myrepo/cat -i cat.tar.gz
Download
smith can also download existing images from docker repositories:smith download -r https://registry-1.docker.io/library/hello-world -i hello-world.tar.gz
latest tag will be
downloaded. To download an alternative tag, append it after a colon:smith download -r https://registry-1.docker.io/library/hello-world:othertag from https://github.com/oracle/smith#readme  
 
No comments:
Post a Comment