![dependabot[bot]](/assets/img/avatar_default.png)
Bumps the golang group with 5 updates: | Package | From | To | | --- | --- | --- | | [github.com/Microsoft/hcsshim](https://github.com/Microsoft/hcsshim) | `0.11.4` | `0.12.0` | | [github.com/alexflint/go-filemutex](https://github.com/alexflint/go-filemutex) | `1.2.0` | `1.3.0` | | [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) | `2.13.2` | `2.16.0` | | [github.com/onsi/gomega](https://github.com/onsi/gomega) | `1.30.0` | `1.31.1` | | [golang.org/x/sys](https://github.com/golang/sys) | `0.15.0` | `0.17.0` | Updates `github.com/Microsoft/hcsshim` from 0.11.4 to 0.12.0 - [Release notes](https://github.com/Microsoft/hcsshim/releases) - [Commits](https://github.com/Microsoft/hcsshim/compare/v0.11.4...v0.12.0) Updates `github.com/alexflint/go-filemutex` from 1.2.0 to 1.3.0 - [Release notes](https://github.com/alexflint/go-filemutex/releases) - [Commits](https://github.com/alexflint/go-filemutex/compare/v1.2.0...v1.3.0) Updates `github.com/onsi/ginkgo/v2` from 2.13.2 to 2.16.0 - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.13.2...v2.16.0) Updates `github.com/onsi/gomega` from 1.30.0 to 1.31.1 - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.30.0...v1.31.1) Updates `golang.org/x/sys` from 0.15.0 to 0.17.0 - [Commits](https://github.com/golang/sys/compare/v0.15.0...v0.17.0) --- updated-dependencies: - dependency-name: github.com/Microsoft/hcsshim dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: github.com/alexflint/go-filemutex dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang ... Signed-off-by: dependabot[bot] <support@github.com>
171 lines
7.4 KiB
Markdown
171 lines
7.4 KiB
Markdown
# hcsshim
|
|
|
|
[](https://github.com/microsoft/hcsshim/actions?query=branch%3Amaster)
|
|
|
|
This package contains the Golang interface for using the Windows [Host Compute Service](https://techcommunity.microsoft.com/t5/containers/introducing-the-host-compute-service-hcs/ba-p/382332) (HCS) to launch and manage [Windows Containers](https://docs.microsoft.com/en-us/virtualization/windowscontainers/about/). It also contains other helpers and functions for managing Windows Containers such as the Golang interface for the Host Network Service (HNS), as well as code for the [guest agent](./internal/guest/README.md) (commonly referred to as the GCS or Guest Compute Service in the codebase) used to support running Linux Hyper-V containers.
|
|
|
|
It is primarily used in the [Moby](https://github.com/moby/moby) and [Containerd](https://github.com/containerd/containerd) projects, but it can be freely used by other projects as well.
|
|
|
|
## Building
|
|
|
|
While this repository can be used as a library of sorts to call the HCS apis, there are a couple binaries built out of the repository as well. The main ones being the Linux guest agent, and an implementation of the [runtime v2 containerd shim api](https://github.com/containerd/containerd/blob/master/runtime/v2/README.md).
|
|
|
|
### Linux Hyper-V Container Guest Agent
|
|
|
|
To build the Linux guest agent itself all that's needed is to set your GOOS to "Linux" and build out of ./cmd/gcs.
|
|
|
|
```powershell
|
|
C:\> $env:GOOS="linux"
|
|
C:\> go build .\cmd\gcs\
|
|
```
|
|
|
|
or on a Linux machine
|
|
|
|
```sh
|
|
> go build ./cmd/gcs
|
|
```
|
|
|
|
If you want it to be packaged inside of a rootfs to boot with alongside all of the other tools then you'll need to provide a rootfs that it can be packaged inside of. An easy way is to export the rootfs of a container.
|
|
|
|
```sh
|
|
docker pull busybox
|
|
docker run --name base_image_container busybox
|
|
docker export base_image_container | gzip > base.tar.gz
|
|
BASE=./base.tar.gz
|
|
make all
|
|
```
|
|
|
|
If the build is successful, in the `./out` folder you should see:
|
|
|
|
```sh
|
|
> ls ./out/
|
|
delta.tar.gz initrd.img rootfs.tar.gz
|
|
```
|
|
|
|
### Containerd Shim
|
|
|
|
For info on the [Runtime V2 API](https://github.com/containerd/containerd/blob/master/runtime/v2/README.md).
|
|
|
|
Contrary to the typical Linux architecture of shim -> runc, the runhcs shim is used both to launch and manage the lifetime of containers.
|
|
|
|
```powershell
|
|
C:\> $env:GOOS="windows"
|
|
C:\> go build .\cmd\containerd-shim-runhcs-v1
|
|
```
|
|
|
|
Then place the binary in the same directory that Containerd is located at in your environment.
|
|
A default Containerd configuration file can be generated by running:
|
|
|
|
```powershell
|
|
.\containerd.exe config default | Out-File "C:\Program Files\containerd\config.toml" -Encoding ascii
|
|
```
|
|
|
|
This config file will already have the shim set as the default runtime for cri interactions.
|
|
|
|
To trial using the shim out with ctr.exe:
|
|
|
|
```powershell
|
|
C:\> ctr.exe run --runtime io.containerd.runhcs.v1 --rm mcr.microsoft.com/windows/nanoserver:2004 windows-test cmd /c "echo Hello World!"
|
|
```
|
|
|
|
## Contributing
|
|
|
|
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
|
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
|
the rights to use your contribution. For details, visit [Microsoft CLA](https://cla.microsoft.com).
|
|
|
|
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
|
|
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
|
|
provided by the bot. You will only need to do this once across all repos using our CLA.
|
|
|
|
We require that contributors sign their commits
|
|
to certify they either authored the work themselves or otherwise have permission to use it in this project.
|
|
|
|
We also require that contributors sign their commits using using [`git commit --signoff`][git-commit-s]
|
|
to certify they either authored the work themselves or otherwise have permission to use it in this project.
|
|
A range of commits can be signed off using [`git rebase --signoff`][git-rebase-s].
|
|
|
|
Please see [the developer certificate](https://developercertificate.org) for more info,
|
|
as well as to make sure that you can attest to the rules listed.
|
|
Our CI uses the [DCO Github app](https://github.com/apps/dco) to ensure that all commits in a given PR are signed-off.
|
|
|
|
### Linting
|
|
|
|
Code must pass a linting stage, which uses [`golangci-lint`][lint].
|
|
Since `./test` is a separate Go module, the linter is run from both the root and the
|
|
`test` directories. Additionally, the linter is run with `GOOS` set to both `windows` and
|
|
`linux`.
|
|
|
|
The linting settings are stored in [`.golangci.yaml`](./.golangci.yaml), and can be run
|
|
automatically with VSCode by adding the following to your workspace or folder settings:
|
|
|
|
```json
|
|
"go.lintTool": "golangci-lint",
|
|
"go.lintOnSave": "package",
|
|
```
|
|
|
|
Additional editor [integrations options are also available][lint-ide].
|
|
|
|
Alternatively, `golangci-lint` can be [installed][lint-install] and run locally:
|
|
|
|
```shell
|
|
# use . or specify a path to only lint a package
|
|
# to show all lint errors, use flags "--max-issues-per-linter=0 --max-same-issues=0"
|
|
> golangci-lint run
|
|
```
|
|
|
|
To run across the entire repo for both `GOOS=windows` and `linux`:
|
|
|
|
```powershell
|
|
> foreach ( $goos in ('windows', 'linux') ) {
|
|
foreach ( $repo in ('.', 'test') ) {
|
|
pwsh -Command "cd $repo && go env -w GOOS=$goos && golangci-lint.exe run --verbose"
|
|
}
|
|
}
|
|
```
|
|
|
|
### Go Generate
|
|
|
|
The pipeline checks that auto-generated code, via `go generate`, are up to date.
|
|
Similar to the [linting stage](#linting), `go generate` is run in both the root and test Go modules.
|
|
|
|
This can be done via:
|
|
|
|
```shell
|
|
> go generate ./...
|
|
> cd test && go generate ./...
|
|
```
|
|
|
|
## Code of Conduct
|
|
|
|
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
|
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
|
|
## Dependencies
|
|
|
|
This project requires Golang 1.18 or newer to build.
|
|
|
|
For system requirements to run this project, see the Microsoft docs on [Windows Container requirements](https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/system-requirements).
|
|
|
|
## Reporting Security Issues
|
|
|
|
Security issues and bugs should be reported privately, via email, to the Microsoft Security
|
|
Response Center (MSRC) at [secure@microsoft.com](mailto:secure@microsoft.com). You should
|
|
receive a response within 24 hours. If for some reason you do not, please follow up via
|
|
email to ensure we received your original message. Further information, including the
|
|
[MSRC PGP](https://technet.microsoft.com/en-us/security/dn606155) key, can be found in
|
|
the [Security TechCenter](https://technet.microsoft.com/en-us/security/default).
|
|
|
|
For additional details, see [Report a Computer Security Vulnerability](https://technet.microsoft.com/en-us/security/ff852094.aspx) on Technet
|
|
|
|
---------------
|
|
Copyright (c) 2018 Microsoft Corp. All rights reserved.
|
|
|
|
[lint]: https://golangci-lint.run/
|
|
[lint-ide]: https://golangci-lint.run/usage/integrations/#editor-integration
|
|
[lint-install]: https://golangci-lint.run/usage/install/#local-installation
|
|
|
|
[git-commit-s]: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--s
|
|
[git-rebase-s]: https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt---signoff
|