{"id":13461556,"url":"https://github.com/opencontainers/runc","last_synced_at":"2025-09-09T20:58:12.260Z","repository":{"id":33315579,"uuid":"36960321","full_name":"opencontainers/runc","owner":"opencontainers","description":"CLI tool for spawning and running containers according to the OCI specification","archived":false,"fork":false,"pushed_at":"2025-05-05T04:31:05.000Z","size":23468,"stargazers_count":12318,"open_issues_count":349,"forks_count":2171,"subscribers_count":377,"default_branch":"main","last_synced_at":"2025-05-05T11:11:29.534Z","etag":null,"topics":["containers","docker","oci"],"latest_commit_sha":null,"homepage":"https://www.opencontainers.org/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opencontainers.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-06-05T23:30:45.000Z","updated_at":"2025-05-05T08:18:46.000Z","dependencies_parsed_at":"2023-09-27T23:09:30.316Z","dependency_job_id":"29c78160-1811-4024-b9e6-e0ae9566e56d","html_url":"https://github.com/opencontainers/runc","commit_stats":{"total_commits":4412,"total_committers":459,"mean_commits":9.612200435729848,"dds":0.7427470534904805,"last_synced_commit":"4ad9f7fd36bdbc931422d2ee446c68311145f519"},"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencontainers%2Frunc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencontainers%2Frunc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencontainers%2Frunc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencontainers%2Frunc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opencontainers","download_url":"https://codeload.github.com/opencontainers/runc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252486917,"owners_count":21755835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["containers","docker","oci"],"created_at":"2024-07-31T11:00:44.040Z","updated_at":"2025-09-09T20:58:12.238Z","avatar_url":"https://github.com/opencontainers.png","language":"Go","readme":"# runc\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/opencontainers/runc)](https://goreportcard.com/report/github.com/opencontainers/runc)\n[![Go Reference](https://pkg.go.dev/badge/github.com/opencontainers/runc.svg)](https://pkg.go.dev/github.com/opencontainers/runc)\n[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/588/badge)](https://bestpractices.coreinfrastructure.org/projects/588)\n[![gha/validate](https://github.com/opencontainers/runc/workflows/validate/badge.svg)](https://github.com/opencontainers/runc/actions?query=workflow%3Avalidate)\n[![gha/ci](https://github.com/opencontainers/runc/workflows/ci/badge.svg)](https://github.com/opencontainers/runc/actions?query=workflow%3Aci)\n[![CirrusCI](https://api.cirrus-ci.com/github/opencontainers/runc.svg)](https://cirrus-ci.com/github/opencontainers/runc)\n\n## Introduction\n\n`runc` is a CLI tool for spawning and running containers on Linux according to the OCI specification.\n\n## Releases\n\nYou can find official releases of `runc` on the [release](https://github.com/opencontainers/runc/releases) page.\n\nAll releases are signed by one of the keys listed in the [`runc.keyring` file in the root of this repository](runc.keyring).\n\n## Security\n\nThe reporting process and disclosure communications are outlined [here](https://github.com/opencontainers/org/blob/master/SECURITY.md).\n\n### Security Audit\nA third party security audit was performed by Cure53, you can see the full report [here](https://github.com/opencontainers/runc/blob/master/docs/Security-Audit.pdf).\n\n## Building\n\n`runc` only supports Linux. See the header of [`go.mod`](./go.mod) for the minimally required Go version.\n\n### Pre-Requisites\n\n#### Utilities and Libraries\n\nIn addition to Go, building `runc` requires multiple utilities and libraries to be installed on your system.\n\nOn Ubuntu/Debian, you can install the required dependencies with:\n\n```bash\napt update \u0026\u0026 apt install -y make gcc linux-libc-dev libseccomp-dev pkg-config git\n```\n\nOn CentOS/Fedora, you can install the required dependencies with:\n\n```bash\nyum install -y make gcc kernel-headers libseccomp-devel pkg-config git\n```\n\nOn Alpine Linux, you can install the required dependencies with:\n\n```bash\napk --update add bash make gcc libseccomp-dev musl-dev linux-headers git\n```\n\nThe following dependencies are optional:\n\n* `libseccomp` - only required if you enable seccomp support; to disable, see [Build Tags](#build-tags)\n\n### Build\n\n```bash\n# create a 'github.com/opencontainers' in your GOPATH/src\ncd github.com/opencontainers\ngit clone https://github.com/opencontainers/runc\ncd runc\n\nmake\nsudo make install\n```\n\nYou can also use `go get` to install to your `GOPATH`, assuming that you have a `github.com` parent folder already created under `src`:\n\n```bash\ngo get github.com/opencontainers/runc\ncd $GOPATH/src/github.com/opencontainers/runc\nmake\nsudo make install\n```\n\n`runc` will be installed to `/usr/local/sbin/runc` on your system.\n\n#### Version string customization\n\nYou can see the runc version by running `runc --version`. You can append a custom string to the\nversion using the `EXTRA_VERSION` make variable when building, e.g.:\n\n```bash\nmake EXTRA_VERSION=\"+build-1\"\n```\n\nBear in mind to include some separator for readability.\n\n#### Build Tags\n\n`runc` supports optional build tags for compiling support of various features,\nwith some of them enabled by default (see `BUILDTAGS` in top-level `Makefile`).\n\nTo change build tags from the default, set the `BUILDTAGS` variable for make,\ne.g. to disable seccomp:\n\n```bash\nmake BUILDTAGS=\"\"\n```\n\nTo add some more build tags to the default set, use the `EXTRA_BUILDTAGS`\nmake variable, e.g. to disable checkpoint/restore:\n\n```bash\nmake EXTRA_BUILDTAGS=\"runc_nocriu\"\n```\n\n| Build Tag     | Feature                               | Enabled by Default | Dependencies        |\n|---------------|---------------------------------------|--------------------|---------------------|\n| `seccomp`     | Syscall filtering using `libseccomp`. | yes                | `libseccomp`        |\n| `runc_nocriu` | **Disables** runc checkpoint/restore. | no                 | `criu`              |\n\nThe following build tags were used earlier, but are now obsoleted:\n - **runc_nodmz** (since runc v1.2.1 runc dmz binary is dropped)\n - **nokmem** (since runc v1.0.0-rc94 kernel memory settings are ignored)\n - **apparmor** (since runc v1.0.0-rc93 the feature is always enabled)\n - **selinux**  (since runc v1.0.0-rc93 the feature is always enabled)\n\n### Running the test suite\n\n`runc` currently supports running its test suite via Docker.\nTo run the suite just type `make test`.\n\n```bash\nmake test\n```\n\nThere are additional make targets for running the tests outside of a container but this is not recommended as the tests are written with the expectation that they can write and remove anywhere.\n\nYou can run a specific test case by setting the `TESTFLAGS` variable.\n\n```bash\n# make test TESTFLAGS=\"-run=SomeTestFunction\"\n```\n\nYou can run a specific integration test by setting the `TESTPATH` variable.\n\n```bash\n# make test TESTPATH=\"/checkpoint.bats\"\n```\n\nYou can run a specific rootless integration test by setting the `ROOTLESS_TESTPATH` variable.\n\n```bash\n# make test ROOTLESS_TESTPATH=\"/checkpoint.bats\"\n```\n\nYou can run a test using your container engine's flags by setting `CONTAINER_ENGINE_BUILD_FLAGS` and `CONTAINER_ENGINE_RUN_FLAGS` variables.\n\n```bash\n# make test CONTAINER_ENGINE_BUILD_FLAGS=\"--build-arg http_proxy=http://yourproxy/\" CONTAINER_ENGINE_RUN_FLAGS=\"-e http_proxy=http://yourproxy/\"\n```\n\n### Go Dependencies Management\n\n`runc` uses [Go Modules](https://github.com/golang/go/wiki/Modules) for dependencies management.\nPlease refer to [Go Modules](https://github.com/golang/go/wiki/Modules) for how to add or update\nnew dependencies.\n\n```\n# Update vendored dependencies\nmake vendor\n# Verify all dependencies\nmake verify-dependencies\n```\n\n## Using runc\n\nPlease note that runc is a low level tool not designed with an end user\nin mind. It is mostly employed by other higher level container software.\n\nTherefore, unless there is some specific use case that prevents the use\nof tools like Docker or Podman, it is not recommended to use runc directly.\n\nIf you still want to use runc, here's how.\n\n### Creating an OCI Bundle\n\nIn order to use runc you must have your container in the format of an OCI bundle.\nIf you have Docker installed you can use its `export` method to acquire a root filesystem from an existing Docker container.\n\n```bash\n# create the top most bundle directory\nmkdir /mycontainer\ncd /mycontainer\n\n# create the rootfs directory\nmkdir rootfs\n\n# export busybox via Docker into the rootfs directory\ndocker export $(docker create busybox) | tar -C rootfs -xvf -\n```\n\nAfter a root filesystem is populated you just generate a spec in the format of a `config.json` file inside your bundle.\n`runc` provides a `spec` command to generate a base template spec that you are then able to edit.\nTo find features and documentation for fields in the spec please refer to the [specs](https://github.com/opencontainers/runtime-spec) repository.\n\n```bash\nrunc spec\n```\n\n### Running Containers\n\nAssuming you have an OCI bundle from the previous step you can execute the container in two different ways.\n\nThe first way is to use the convenience command `run` that will handle creating, starting, and deleting the container after it exits.\n\n```bash\n# run as root\ncd /mycontainer\nrunc run mycontainerid\n```\n\nIf you used the unmodified `runc spec` template this should give you a `sh` session inside the container.\n\nThe second way to start a container is using the specs lifecycle operations.\nThis gives you more power over how the container is created and managed while it is running.\nThis will also launch the container in the background so you will have to edit\nthe `config.json` to remove the `terminal` setting for the simple examples\nbelow (see more details about [runc terminal handling](docs/terminals.md)).\nYour process field in the `config.json` should look like this below with `\"terminal\": false` and `\"args\": [\"sleep\", \"5\"]`.\n\n\n```json\n        \"process\": {\n                \"terminal\": false,\n                \"user\": {\n                        \"uid\": 0,\n                        \"gid\": 0\n                },\n                \"args\": [\n                        \"sleep\", \"5\"\n                ],\n                \"env\": [\n                        \"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\",\n                        \"TERM=xterm\"\n                ],\n                \"cwd\": \"/\",\n                \"capabilities\": {\n                        \"bounding\": [\n                                \"CAP_AUDIT_WRITE\",\n                                \"CAP_KILL\",\n                                \"CAP_NET_BIND_SERVICE\"\n                        ],\n                        \"effective\": [\n                                \"CAP_AUDIT_WRITE\",\n                                \"CAP_KILL\",\n                                \"CAP_NET_BIND_SERVICE\"\n                        ],\n                        \"inheritable\": [\n                                \"CAP_AUDIT_WRITE\",\n                                \"CAP_KILL\",\n                                \"CAP_NET_BIND_SERVICE\"\n                        ],\n                        \"permitted\": [\n                                \"CAP_AUDIT_WRITE\",\n                                \"CAP_KILL\",\n                                \"CAP_NET_BIND_SERVICE\"\n                        ],\n                        \"ambient\": [\n                                \"CAP_AUDIT_WRITE\",\n                                \"CAP_KILL\",\n                                \"CAP_NET_BIND_SERVICE\"\n                        ]\n                },\n                \"rlimits\": [\n                        {\n                                \"type\": \"RLIMIT_NOFILE\",\n                                \"hard\": 1024,\n                                \"soft\": 1024\n                        }\n                ],\n                \"noNewPrivileges\": true\n        },\n```\n\nNow we can go through the lifecycle operations in your shell.\n\n\n```bash\n# run as root\ncd /mycontainer\nrunc create mycontainerid\n\n# view the container is created and in the \"created\" state\nrunc list\n\n# start the process inside the container\nrunc start mycontainerid\n\n# after 5 seconds view that the container has exited and is now in the stopped state\nrunc list\n\n# now delete the container\nrunc delete mycontainerid\n```\n\nThis allows higher level systems to augment the containers creation logic with setup of various settings after the container is created and/or before it is deleted. For example, the container's network stack is commonly set up after `create` but before `start`.\n\n#### Rootless containers\n`runc` has the ability to run containers without root privileges. This is called `rootless`. You need to pass some parameters to `runc` in order to run rootless containers. See below and compare with the previous version.\n\n**Note:** In order to use this feature, \"User Namespaces\" must be compiled and enabled in your kernel. There are various ways to do this depending on your distribution:\n- Confirm `CONFIG_USER_NS=y` is set in your kernel configuration (normally found in `/proc/config.gz`)\n- Arch/Debian: `echo 1 \u003e /proc/sys/kernel/unprivileged_userns_clone`\n- RHEL/CentOS 7: `echo 28633 \u003e /proc/sys/user/max_user_namespaces`\n\nRun the following commands as an ordinary user:\n```bash\n# Same as the first example\nmkdir ~/mycontainer\ncd ~/mycontainer\nmkdir rootfs\ndocker export $(docker create busybox) | tar -C rootfs -xvf -\n\n# The --rootless parameter instructs runc spec to generate a configuration for a rootless container, which will allow you to run the container as a non-root user.\nrunc spec --rootless\n\n# The --root parameter tells runc where to store the container state. It must be writable by the user.\nrunc --root /tmp/runc run mycontainerid\n```\n\n#### Supervisors\n\n`runc` can be used with process supervisors and init systems to ensure that containers are restarted when they exit.\nAn example systemd unit file looks something like this.\n\n```systemd\n[Unit]\nDescription=Start My Container\n\n[Service]\nType=forking\nExecStart=/usr/local/sbin/runc run -d --pid-file /run/mycontainerid.pid mycontainerid\nExecStopPost=/usr/local/sbin/runc delete mycontainerid\nWorkingDirectory=/mycontainer\nPIDFile=/run/mycontainerid.pid\n\n[Install]\nWantedBy=multi-user.target\n```\n\n## More documentation\n\n* [Spec conformance](./docs/spec-conformance.md)\n* [cgroup v2](./docs/cgroup-v2.md)\n* [Checkpoint and restore](./docs/checkpoint-restore.md)\n* [systemd cgroup driver](./docs/systemd.md)\n* [Terminals and standard IO](./docs/terminals.md)\n* [Experimental features](./docs/experimental.md)\n\n## License\n\nThe code and docs are released under the [Apache 2.0 license](LICENSE).\n","funding_links":[],"categories":["Misc","Go","Tools for Self-Hosting","docker","OCI runtimes:","Uncategorized","Project/Product","Containers","HarmonyOS","oci","Applications","Container runtimes"],"sub_categories":["Containers","Uncategorized","Threat modelling","Windows Manager","Container"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopencontainers%2Frunc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopencontainers%2Frunc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopencontainers%2Frunc/lists"}