Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Renamed to ctnr
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoltzsche committed Oct 18, 2018
1 parent 5edab9a commit 4f4ee63
Show file tree
Hide file tree
Showing 110 changed files with 331 additions and 333 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
/dist/
/vendor/
test-resources/volumes/

# Dockerfile shell words parser workaround
image/builder/dockerfile/shell/parser.go
ctnr
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:alpine3.8 AS cntnr-build
FROM golang:alpine3.8 AS ctnr-build
RUN apk add --update --no-cache gcc musl-dev libseccomp-dev btrfs-progs-dev lvm2-dev make git

FROM fedora:28 as proot
Expand Down Expand Up @@ -26,7 +26,7 @@ WORKDIR /PRoot/src
ENV PKG_CONFIG_PATH=/usr/lib/pkgconfig
RUN make && mv proot / && make clean

FROM cntnr-build AS liteide
FROM ctnr-build AS liteide
ARG LITEIDE_PKGS="g++ qt5-qttools qt5-qtbase-dev qt5-qtbase-x11 qt5-qtwebkit xkeyboard-config libcanberra-gtk3 adwaita-icon-theme ttf-dejavu"
RUN apk add --update --no-cache ${LITEIDE_PKGS} || /usr/lib/qt5/bin/qmake -help >/dev/null
RUN git clone https://github.com/visualfc/liteide.git \
Expand Down
42 changes: 21 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
BUILDIMAGE=local/cntnr-build:latest
LITEIDEIMAGE=local/cntnr-build:liteide
DOCKERRUN=docker run --name cntnr-build --rm -v "${REPODIR}:/work" -w /work -u `id -u`:`id -u`
BUILDIMAGE=local/ctnr-build:latest
LITEIDEIMAGE=local/ctnr-build:liteide
DOCKERRUN=docker run --name ctnr-build --rm -v "${REPODIR}:/work" -w /work -u `id -u`:`id -u`

REPODIR=$(shell pwd)
GOPATH=${REPODIR}/build
LITEIDE_WORKSPACE=${GOPATH}/liteide-workspace
PKGNAME=github.com/mgoltzsche/cntnr
PKGNAME=github.com/mgoltzsche/ctnr
PKGRELATIVEROOT=$(shell echo /src/${PKGNAME} | sed -E 's/\/+[^\/]*/..\//g')
VENDORLOCK=${REPODIR}/vendor/ready
BINARY=cntnr
BINARY=ctnr

# 'apparmor' tag cannot be used for runc yet since package is not yet available in alpine:3.7
BUILDTAGS_RUNC=seccomp selinux ambient
BUILDTAGS?=containers_image_ostree_stub containers_image_storage_stub containers_image_openpgp libdm_no_deferred_remove btrfs_noversion ${BUILDTAGS_RUNC}
BUILDTAGS_STATIC=${BUILDTAGS} linux static_build exclude_graphdriver_devicemapper mgoltzsche_cntnr_libcontainer
BUILDTAGS_STATIC=${BUILDTAGS} linux static_build exclude_graphdriver_devicemapper mgoltzsche_ctnr_libcontainer
LDFLAGS_STATIC=${LDFLAGS} -extldflags '-static'

CNI_VERSION=0.6.0
CNIGOPATH=${GOPATH}/cni

COBRA=${GOPATH}/bin/cobra
PACKAGES:=$(shell go list $(BUILDFLAGS) . | grep -v github.com/mgoltzsche/cntnr/vendor)
PACKAGES:=$(shell go list $(BUILDFLAGS) . | grep -v github.com/mgoltzsche/ctnr/vendor)

export PATH := dist/bin:$(PATH)

Expand All @@ -38,19 +38,19 @@ generate: dependencies
GOPATH="${GOPATH}" \
go get github.com/golang/protobuf/protoc-gen-go
# GOPATH="${GOPATH}"
cd "${GOPATH}"/src/github.com/mgoltzsche/cntnr/vendor/github.com/rootless-containers/proto && \
cd "${GOPATH}"/src/github.com/mgoltzsche/ctnr/vendor/github.com/rootless-containers/proto && \
"${GOPATH}/bin/protoc-gen-go" --go_out=. rootlesscontainers.proto

test: dependencies
# Run tests
export GOPATH="${GOPATH}"; \
#go test -tags "${BUILDTAGS}" -coverprofile "${GOPATH}/coverage.out" -cover `cd "${GOPATH}/src/${PKGNAME}" && go list -tags "${BUILDTAGS}" ./... | grep -Ev '/vendor/|^${PKGNAME}/build/'`
export GOPATH="${GOPATH}"; cd "${GOPATH}/src/github.com/mgoltzsche/cntnr/image/builder" && go test -tags "${BUILDTAGS}" -run ImageBuilder
go test -tags "${BUILDTAGS}" -coverprofile "${GOPATH}/coverage.out" -cover $(shell export GOPATH="${GOPATH}"; cd "${GOPATH}/src/${PKGNAME}" && go list -tags "${BUILDTAGS_STATIC}" ./... 2>/dev/null | grep -Ev '/vendor/|^${PKGNAME}/build/')
#export GOPATH="${GOPATH}"; cd "${GOPATH}/src/github.com/mgoltzsche/ctnr/image/builder" && go test -tags "${BUILDTAGS}" -run ImageBuilder

test-static: dependencies
# Run tests using BUILDTAGS_STATIC
export GOPATH="${GOPATH}"; \
go test -tags "${BUILDTAGS_STATIC}" -coverprofile "${GOPATH}/coverage.out" -cover `cd "${GOPATH}/src/${PKGNAME}" && go list -tags "${BUILDTAGS_STATIC}" ./... | grep -Ev '/vendor/|^${PKGNAME}/build/'`
go test -tags "${BUILDTAGS_STATIC}" -coverprofile "${GOPATH}/coverage.out" -cover $(shell export GOPATH="${GOPATH}"; cd "${GOPATH}/src/${PKGNAME}" && go list -tags "${BUILDTAGS_STATIC}" ./... 2>/dev/null | grep -Ev '/vendor/|^${PKGNAME}/build/')

test-coverage: test
GOPATH="${GOPATH}" go tool cover -html="${GOPATH}/coverage.out"
Expand Down Expand Up @@ -99,7 +99,7 @@ cni-plugins:

.buildimage:
# Building build image:
docker build -t ${BUILDIMAGE} --target cntnr-build .
docker build -t ${BUILDIMAGE} --target ctnr-build .

build-sh: .buildimage
# Running dockerized interactive build shell
Expand Down Expand Up @@ -136,8 +136,8 @@ cobra: .workspace
"${GOPATH}/bin/cobra"

proot:
cntnr image create --verbose --dockerfile Dockerfile --target proot --tag local/proot
cntnr bundle create -b "${GOPATH}/proot-bundle" --update local/proot
ctnr image build --verbose --dockerfile Dockerfile --target proot --tag local/proot
ctnr bundle create -b "${GOPATH}/proot-bundle" --update local/proot
cp "${GOPATH}/proot-bundle/rootfs/proot" "${REPODIR}/dist/bin/proot"

liteide: dependencies
Expand All @@ -163,24 +163,24 @@ liteide: dependencies

ide: .liteideimage
# Make sure to lock the build path to the top-level directory
cntnr bundle create -b cntnr-liteide --update=true -w /work \
--mount "src=${REPODIR},dst=/work/src/github.com/mgoltzsche/cntnr" \
ctnr bundle create -b ctnr-liteide --update=true -w /work \
--mount "src=${REPODIR},dst=/work/src/github.com/mgoltzsche/ctnr" \
--mount "src=${REPODIR}/liteide.ini,dst=/root/.config/liteide/liteide.ini" \
--mount src=/etc/machine-id,dst=/etc/machine-id,opt=ro \
--mount src=/tmp/.X11-unix,dst=/tmp/.X11-unix \
--env DISPLAY=$$DISPLAY \
--env GOPATH=/work \
${LITEIDEIMAGE} \
liteide /work/src/github.com/mgoltzsche/cntnr
cntnr bundle run --verbose cntnr-liteide &
liteide /work/src/github.com/mgoltzsche/ctnr
ctnr bundle run --verbose ctnr-liteide &

.liteideimage:
cntnr image create --dockerfile=Dockerfile --target=liteide --tag=${LITEIDEIMAGE}
ctnr image build --dockerfile=Dockerfile --target=liteide --tag=${LITEIDEIMAGE}

LITEIDE_PKGS=g++ qt5-qttools qt5-qtbase-dev qt5-qtbase-x11 qt5-qtwebkit xkeyboard-config libcanberra-gtk3 adwaita-icon-theme ttf-dejavu
.OLD_liteideimage: .buildimage
# TODO: clean this up when --workdir and --env options are supported
cntnr image create \
ctnr image build \
--from=docker-daemon:${BUILDIMAGE} \
--author='Max Goltzsche <[email protected]>' \
--run-sh='cd / && git clone https://github.com/visualfc/liteide.git \
Expand All @@ -191,7 +191,7 @@ LITEIDE_PKGS=g++ qt5-qttools qt5-qtbase-dev qt5-qtbase-x11 qt5-qtwebkit xkeyboar
--tag=${LITEIDEIMAGE}

install:
cp dist/bin/cntnr /usr/local/bin/cntnr
cp dist/bin/ctnr /usr/local/bin/ctnr

clean:
rm -rf ./build ./dist
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# cntnr
# ctnr

CNTNR DEVELOPMENT IS IN AN EARLY STATE!

cntnr is a CLI built on top of [runc](https://github.com/opencontainers/runc)
ctnr is a CLI built on top of [runc](https://github.com/opencontainers/runc)
to manage and build OCI images as well as containers.
cntnr aims to ease system container creation and execution as unprivileged user.
Also cntnr is a platform to try out new runc features.
ctnr aims to ease system container creation and execution as unprivileged user.
Also ctnr is a platform to try out new runc features.


## Features
Expand Down Expand Up @@ -47,7 +47,7 @@ As a result in a restrictive environment without root access only the host netwo
This is caused by the fact that all operations in the container are still run by the host user (who is just mapped to user 0 inside the container).
Unfortunately this stops many package managers as well as official docker images from working:
While `apk` already works with plain [runc](https://github.com/opencontainers/runc) `apt-get` does not since it requires to change a user permanently.
To overcome this limitation cntnr supports the `user.rootlesscontainers` xattr and integrates with [PRoot](https://github.com/rootless-containers/PRoot)*.
To overcome this limitation ctnr supports the `user.rootlesscontainers` xattr and integrates with [PRoot](https://github.com/rootless-containers/PRoot)*.


For more details see Aleksa Sarai's [summary](https://rootlesscontaine.rs/) of the state of the art of rootless containers.
Expand All @@ -58,17 +58,17 @@ For more details see Aleksa Sarai's [summary](https://rootlesscontaine.rs/) of t

## Build

Build the binary `dist/bin/cntnr` as well as `dist/bin/cni-plugins` on a Linux machine with git, make and docker:
Build the binary `dist/bin/ctnr` as well as `dist/bin/cni-plugins` on a Linux machine with git, make and docker:
```
git clone https://github.com/mgoltzsche/cntnr.git
cd cntnr
git clone https://github.com/mgoltzsche/ctnr.git
cd ctnr
make
```
Install in `/usr/local`:
```
sudo make install
```
Optionally the project can now be opened with LiteIDE running in a cntnr container
Optionally the project can now be opened with LiteIDE running in a ctnr container
_(Please note that it takes some time to build the LiteIDE container image)_:
```
make ide
Expand All @@ -81,14 +81,14 @@ The following examples assume your policy accepts docker images or you have copi

### Create and run container from Docker image
```
$ cntnr run docker://alpine:3.8 echo hello world
$ ctnr run docker://alpine:3.8 echo hello world
hello world
```

### Create and run Firefox as unprivileged user
Build a Firefox ESR container image `local/firefox:alpine` (cached operation):
```
$ cntnr image build \
$ ctnr image build \
--from=docker://alpine:3.8 \
--author='John Doe' \
--run='apk add --update --no-cache firefox-esr libcanberra-gtk3 adwaita-icon-theme ttf-ubuntu-font-family' \
Expand All @@ -98,7 +98,7 @@ $ cntnr image build \

Create and run a bundle named `firefox` from the previously built image:
```
$ cntnr run -b firefox --update \
$ ctnr run -b firefox --update \
--env DISPLAY=$DISPLAY \
--mount src=/tmp/.X11-unix,dst=/tmp/.X11-unix \
--mount src=/etc/machine-id,dst=/etc/machine-id,opt=ro \
Expand All @@ -107,11 +107,11 @@ $ cntnr run -b firefox --update \
_(Unfortunately tabs in firefox tend to crash)_
The `-b <BUNDLE>` and `--update` options make this operation idempotent:
The bundle's file system is reused and only recreated when the underlying image has changed.
Use these options to restart containers very quickly. Without them cntnr copies the
Use these options to restart containers very quickly. Without them ctnr copies the
image file system on bundle creation which can take some time and disk space depending on the image's size.
Also these options enable a container update on restart when the base image is frequently updated before the child image is rebuilt using the following command:
```
$ cntnr image import docker://alpine:3.8
$ ctnr image import docker://alpine:3.8
```

### Build Dockerfile as unprivileged user
Expand All @@ -123,13 +123,13 @@ FROM debian:9
RUN apt-get update && apt-get install -y cowsay
ENTRYPOINT ["/usr/games/cowsay"]
```
Build the image (Please note that this works only with `--proot` enabled. With plain cntnr/runc `apt-get` fails to change uid/gid.):
Build the image (Please note that this works only with `--proot` enabled. With plain ctnr/runc `apt-get` fails to change uid/gid.):
```
$ cntnr image build --proot --dockerfile Dockerfile-cowsay --tag example/cowsay
$ ctnr image build --proot --dockerfile Dockerfile-cowsay --tag example/cowsay
```
Run a container using the previously built image (Please note that `--proot` is not required anymore):
```
$ cntnr run example/cowsay hello from container
$ ctnr run example/cowsay hello from container
______________________
< hello from container >
----------------------
Expand All @@ -144,21 +144,21 @@ $ cntnr run example/cowsay hello from container
## The OCI standard and this implementation

An *[OCI image](https://github.com/opencontainers/image-spec/tree/v1.0.0)* provides a base [configuration](https://github.com/opencontainers/image-spec/blob/v1.0.0/config.md) and file system to create an OCI bundle from. The file system consists of a list of layers represented by tar files each containing the diff to its predecessor.
cntnr manages images in its local store directory in the [OCI image layout format](https://github.com/opencontainers/image-spec/blob/v1.0.0/image-layout.md).
ctnr manages images in its local store directory in the [OCI image layout format](https://github.com/opencontainers/image-spec/blob/v1.0.0/image-layout.md).
Images are imported into the local store using the [containers/image](https://github.com/containers/image) library.
A new bundle is created by extracting the image's file system into a directory and [deriving](https://github.com/opencontainers/image-spec/blob/v1.0.0/conversion.md) the bundle's default configuration from the image's configuration plus user-defined options.


An *[OCI bundle](https://github.com/opencontainers/runtime-spec/blob/v1.0.0/bundle.md)* describes a container by
a [configuration](https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md) and a file system.
Basically it is a directory containing a `config.json` file with the configuration and a sub directory with the root file system.
cntnr manages bundles in its local store directory. Alternatively a custom directory can also be used as bundle.
OCI bundles generated by cntnr can also be run with other OCI-compliant container engines as [runc](https://github.com/opencontainers/runc/).
ctnr manages bundles in its local store directory. Alternatively a custom directory can also be used as bundle.
OCI bundles generated by ctnr can also be run with other OCI-compliant container engines as [runc](https://github.com/opencontainers/runc/).


An *[OCI container](https://github.com/opencontainers/runtime-spec/blob/v1.0.0/runtime.md)* is a host-specific bundle instance.
On Linux it is a set of namespaces in which a configured process can be run.
cntnr provides two wrapper implementations of the OCI runtime reference implementation
ctnr provides two wrapper implementations of the OCI runtime reference implementation
[runc/libcontainer](https://github.com/opencontainers/runc/blob/v1.0.0-rc5/libcontainer/README.md)
to either use an external runc binary or use libcontainer (no runtime dependencies!) controlled by a compiler flag.

Expand All @@ -181,11 +181,10 @@ to either use an external runc binary or use libcontainer (no runtime dependenci
## Roadmap / TODO

- clean up CLI
- change project name
- setup CI/CD
- **0.7 beta release**
- system.Context aware processes, unpacking/packing images
- improved docker CLI compatibility regarding `build` and `run` commands in order to use cntnr to substitute docker easily in common build operations
- improved docker CLI compatibility regarding `build` and `run` commands in order to use ctnr to substitute docker easily in common build operations
- improved multi-user support (store per user group, file permissions, lock location)
- CLI integration tests
- rootless networking (using proot port mapping or tun/tap CNI plugin)
Expand Down
8 changes: 4 additions & 4 deletions bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import (
"strings"
"time"

"github.com/mgoltzsche/cntnr/pkg/atomic"
exterrors "github.com/mgoltzsche/cntnr/pkg/errors"
"github.com/mgoltzsche/cntnr/pkg/lock"
"github.com/mgoltzsche/ctnr/pkg/atomic"
exterrors "github.com/mgoltzsche/ctnr/pkg/errors"
"github.com/mgoltzsche/ctnr/pkg/lock"
"github.com/openSUSE/umoci/pkg/fseval"
digest "github.com/opencontainers/go-digest"
rspecs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
)

const ANNOTATION_BUNDLE_ID = "com.github.mgoltzsche.cntnr.bundle.id"
const ANNOTATION_BUNDLE_ID = "com.github.mgoltzsche.ctnr.bundle.id"

type Bundle struct {
id string
Expand Down
2 changes: 1 addition & 1 deletion bundle/bundlebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/base32"
"strings"

"github.com/mgoltzsche/cntnr/pkg/generate"
"github.com/mgoltzsche/ctnr/pkg/generate"
"github.com/pkg/errors"
"github.com/satori/go.uuid"
)
Expand Down
6 changes: 3 additions & 3 deletions bundle/store/bundlestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"path/filepath"
"time"

"github.com/mgoltzsche/cntnr/bundle"
exterrors "github.com/mgoltzsche/cntnr/pkg/errors"
"github.com/mgoltzsche/cntnr/pkg/log"
"github.com/mgoltzsche/ctnr/bundle"
exterrors "github.com/mgoltzsche/ctnr/pkg/errors"
"github.com/mgoltzsche/ctnr/pkg/log"
"github.com/pkg/errors"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"time"

humanize "github.com/dustin/go-humanize"
"github.com/mgoltzsche/cntnr/bundle"
"github.com/mgoltzsche/cntnr/run"
"github.com/mgoltzsche/ctnr/bundle"
"github.com/mgoltzsche/ctnr/run"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"fmt"
"path/filepath"

"github.com/mgoltzsche/cntnr/image"
"github.com/mgoltzsche/cntnr/pkg/fs/tree"
"github.com/mgoltzsche/ctnr/image"
"github.com/mgoltzsche/ctnr/pkg/fs/tree"
"github.com/opencontainers/go-digest"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down
18 changes: 9 additions & 9 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (
"runtime/debug"
"strings"

"github.com/mgoltzsche/cntnr/bundle"
"github.com/mgoltzsche/cntnr/image"
"github.com/mgoltzsche/cntnr/model"
"github.com/mgoltzsche/cntnr/model/oci"
exterrors "github.com/mgoltzsche/cntnr/pkg/errors"
"github.com/mgoltzsche/cntnr/run"
"github.com/mgoltzsche/cntnr/run/factory"
"github.com/mgoltzsche/ctnr/bundle"
"github.com/mgoltzsche/ctnr/image"
"github.com/mgoltzsche/ctnr/model"
"github.com/mgoltzsche/ctnr/model/oci"
exterrors "github.com/mgoltzsche/ctnr/pkg/errors"
"github.com/mgoltzsche/ctnr/run"
"github.com/mgoltzsche/ctnr/run/factory"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -40,10 +40,10 @@ func wrapRun(cf func(cmd *cobra.Command, args []string) error) func(cmd *cobra.C
if err := recover(); err != nil {
msg := "\n OUPS, THIS SEEMS TO BE A BUG!"
msg += "\n Please report it at"
msg += "\n https://github.com/mgoltzsche/cntnr/issues/new"
msg += "\n https://github.com/mgoltzsche/ctnr/issues/new"
msg += "\n with a description of what you did and the stacktrace"
msg += "\n below if you cannot find an already existing issue at"
msg += "\n https://github.com/mgoltzsche/cntnr/issues\n"
msg += "\n https://github.com/mgoltzsche/ctnr/issues\n"
stackTrace := strings.Replace(string(debug.Stack()), "\n", "\n ", -1)
// TODO: Add version
logrus.Fatalf("%+v\n%s\n PANIC: %s\n %s", err, msg, err, stackTrace)
Expand Down
4 changes: 2 additions & 2 deletions cmd/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package cmd

import (
"github.com/mgoltzsche/cntnr/model"
"github.com/mgoltzsche/cntnr/model/compose"
"github.com/mgoltzsche/ctnr/model"
"github.com/mgoltzsche/ctnr/model/compose"
"github.com/spf13/cobra"
)

Expand Down
Loading

0 comments on commit 4f4ee63

Please sign in to comment.