Skip to content

Instantly share code, notes, and snippets.

@r10r
Forked from jzaccone/runc_with_tty.md
Created October 7, 2021 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r10r/5c2d1a77af9f581cf8e8705cf2379229 to your computer and use it in GitHub Desktop.
Save r10r/5c2d1a77af9f581cf8e8705cf2379229 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