Skip to content

Instantly share code, notes, and snippets.

@jzaccone
Last active October 7, 2021 07:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jzaccone/1c57d20e71450ca8e60e86a2e6578a33 to your computer and use it in GitHub Desktop.
Save jzaccone/1c57d20e71450ca8e60e86a2e6578a33 to your computer and use it in GitHub Desktop.
Start runC container with TTY Device

About

recvtty is a reference implementation of a consumer of runC's --console-socket API. It is automatically built when doing a make on the runc project.

Prereq

These instructions were tested on Ubuntu 16.04. Also go, git are required.

Install runC

go get github.com/opencontainers/runc
cd $GOPATH/src/github.com/opencontainers/runc
make all # make tests will build the recvtty test tool and make install will install runc

Create a runC bundle to test with

# create the top most bundle directory
mkdir /mycontainer
cd /mycontainer
# create the rootfs directory
mkdir rootfs
# export busybox via Docker into the rootfs directory
sudo docker export $(sudo docker create busybox) | tar -C rootfs -xvf -

# Create config.json
runc spec

Launch the recvtty tool to listen on the socket

contrib/cmd/recvtty/recvtty ~/test.sock

Then launch the container in a new console

cd mycontainer
sudo runc create --console-socket ~/foo.sock hello
sudo runc start hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment