| 1 | [](https://linuxcontainers.org/) |
| 2 | # Go Bindings for LXC (Linux Containers) |
| 3 | |
| 4 | LXC is the well-known and heavily tested low-level Linux container runtime. It |
| 5 | is in active development since 2008 and has proven itself in critical |
| 6 | production environments world-wide. Some of its core contributors are the same |
| 7 | people that helped to implement various well-known containerization features |
| 8 | inside the Linux kernel. |
| 9 | |
| 10 | |
| 11 | This package implements [Go](https://golang.org) bindings for the [LXC](https://linuxcontainers.org/lxc/introduction/) C API (liblxc). |
| 12 | |
| 13 | ## Status |
| 14 | Type | Service | Status |
| 15 | --- | --- | --- |
| 16 | CI (Linux) | Github | [](https://github.com/lxc/go-lxc/actions/workflows/test.yml) |
| 17 | Go documentation | Godoc | [](https://godoc.org/github.com/lxc/go-lxc) |
| 18 | Static analysis | GoReport | [](https://goreportcard.com/report/github.com/lxc/go-lxc) |
| 19 | |
| 20 | ## Requirements |
| 21 | |
| 22 | This package requires [LXC >= 1.0.0](https://github.com/lxc/lxc/releases) and its development package and their dependencies to be installed. Additionally, go-lxc requires Golang 1.10 or later to work. Following command should install required dependencies on Ubuntu 18.10: |
| 23 | |
| 24 | ```bash |
| 25 | sudo apt update |
| 26 | sudo apt install git golang gcc make liblxc1 liblxc-dev lxc-utils pkg-config |
| 27 | ``` |
| 28 | |
| 29 | ## Installing |
| 30 | |
| 31 | To install it, run: |
| 32 | |
| 33 | ```bash |
| 34 | go get github.com/lxc/go-lxc |
| 35 | ``` |
| 36 | |
| 37 | ## Trying |
| 38 | |
| 39 | To try examples, run: |
| 40 | |
| 41 | ```bash |
| 42 | # cd ~/go/src/github.com/lxc/go-lxc/examples/ |
| 43 | |
| 44 | # make |
| 45 | ==> Running go vet |
| 46 | ==> Building ... |
| 47 | ... |
| 48 | |
| 49 | # create/create |
| 50 | 2018/12/27 22:39:27 Creating container... |
| 51 | |
| 52 | # start/start |
| 53 | 2018/12/27 22:39:39 Starting the container... |
| 54 | 2018/12/27 22:39:39 Waiting container to startup networking... |
| 55 | |
| 56 | # attach/attach |
| 57 | 2018/12/27 22:39:46 AttachShell |
| 58 | root@rubik:/# hostname |
| 59 | rubik |
| 60 | root@rubik:/# exit |
| 61 | exit |
| 62 | 2018/12/27 22:39:52 RunCommand |
| 63 | uid=0(root) gid=0(root) groups=0(root) |
| 64 | |
| 65 | # stop/stop |
| 66 | 2018/12/27 22:39:54 Stopping the container... |
| 67 | |
| 68 | # destroy/destroy |
| 69 | 2018/12/27 22:39:57 Destroying container... |
| 70 | ``` |
| 71 | |
| 72 | ## Backwards Compatibility |
| 73 | |
| 74 | LXC has always focused on strong backwards compatibility. In fact, the API hasn't been broken from release `1.0.0` onwards. Main LXC is currently at version `2.*.*`. |
| 75 | |
| 76 | ## Examples |
| 77 | |
| 78 | See the [examples](https://github.com/lxc/go-lxc/tree/v2/examples) directory for some. |
| 79 | |
| 80 | ## Bug reports |
| 81 | |
| 82 | Bug reports can be filed at: <https://github.com/lxc/go-lxc/issues/new> |
| 83 | |
| 84 | ## Contributing |
| 85 | |
| 86 | Fixes and new features are greatly appreciated. We'd love to see go-lxc improve. To contribute to go-lxc; |
| 87 | |
| 88 | * **Fork** the repository |
| 89 | * **Modify** your fork |
| 90 | * Ensure your fork **passes all tests** |
| 91 | * **Send** a pull request |
| 92 | * Bonus points if the pull request includes *what* you changed, *why* you changed it, and *tests* attached. |
| 93 | |
| 94 | ## Getting help |
| 95 | |
| 96 | When you find you need help, the LXC projects provides you with several options. |
| 97 | |
| 98 | ### Discuss Forum |
| 99 | |
| 100 | We maintain an discuss forum at |
| 101 | |
| 102 | - https://discuss.linuxcontainers.org/ |
| 103 | |
| 104 | where you can get support. |
| 105 | |
| 106 | ### IRC |
| 107 | |
| 108 | You can find support by joining `#lxcontainers` on `Freenode`. |
| 109 | |
| 110 | ### Mailing Lists |
| 111 | |
| 112 | You can check out one of the two LXC mailing list archives and register if interested: |
| 113 | |
| 114 | - http://lists.linuxcontainers.org/listinfo/lxc-devel |
| 115 | - http://lists.linuxcontainers.org/listinfo/lxc-users |