Skip to content

Commit 4f3bdf0

Browse files
committed
Run windows containers
Signed-off-by: James Sturtevant <[email protected]>
1 parent 5b52e3b commit 4f3bdf0

14 files changed

+407
-197
lines changed

.cirrus.yml

+13
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,16 @@ task:
1212
- go test -v ./pkg/...
1313
- cd cmd/nerdctl
1414
- sudo go run . run $NERDCTL_RUN_ARGS | grep running
15+
16+
docker_builder:
17+
name: windows
18+
platform: windows
19+
os_version: 2019
20+
env:
21+
CGO_ENABLED: 0
22+
build_script:
23+
- mkdir "C:\Windows\system32\config\systemprofile\AppData\Local\Temp\"
24+
- powershell hack/configure-windows-ci.ps1
25+
- refreshenv
26+
- go install .\cmd\nerdctl\
27+
- go test -v -run "^(TestRunWorkdir|TestRunWithDoubleDash|TestRunExitCode|TestRunCIDFile|TestRunEnvFile|TestRunEnv|TestExec|ImageInspect|TestRunUserName)$" ./cmd/...

README.md

+31-29
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ See [`./docs/freebsd.md`](docs/freebsd.md).
9696
### Windows
9797

9898
- Linux containers: Known to work on WSL2
99-
- Windows containers: WIP, see [PR #197](https://github.com/containerd/nerdctl/pull/197)
99+
- Windows containers: experimental support for Windows (see below for features that are currently known to work)
100100

101101
### Docker
102102

@@ -194,6 +194,8 @@ Please certify your [Developer Certificate of Origin (DCO)](https://developercer
194194

195195
:nerd_face: = nerdctl specific
196196

197+
:window: = Windows enabled
198+
197199
Unlisted `docker` CLI flags are unimplemented yet in `nerdctl` CLI.
198200
It does not necessarily mean that the corresponding features are missing in containerd.
199201

@@ -202,10 +204,10 @@ It does not necessarily mean that the corresponding features are missing in cont
202204

203205

204206
- [Run & Exec](#run--exec)
205-
- [:whale: nerdctl run](#whale-nerdctl-run)
206-
- [:whale: nerdctl exec](#whale-nerdctl-exec)
207+
- [:whale: :window: nerdctl run](#whale-nerdctl-run)
208+
- [:whale: :window: nerdctl exec](#whale-nerdctl-exec)
207209
- [Container management](#container-management)
208-
- [:whale: nerdctl ps](#whale-nerdctl-ps)
210+
- [:whale: :window: nerdctl ps](#whale-nerdctl-ps)
209211
- [:whale: nerdctl inspect](#whale-nerdctl-inspect)
210212
- [:whale: nerdctl logs](#whale-nerdctl-logs)
211213
- [:whale: nerdctl port](#whale-nerdctl-port)
@@ -221,8 +223,8 @@ It does not necessarily mean that the corresponding features are missing in cont
221223
- [:whale: nerdctl build](#whale-nerdctl-build)
222224
- [:whale: nerdctl commit](#whale-nerdctl-commit)
223225
- [Image management](#image-management)
224-
- [:whale: nerdctl images](#whale-nerdctl-images)
225-
- [:whale: nerdctl pull](#whale-nerdctl-pull)
226+
- [:whale: :window: nerdctl images](#whale-nerdctl-images)
227+
- [:whale: :window: nerdctl pull](#whale-nerdctl-pull)
226228
- [:whale: nerdctl push](#whale-nerdctl-push)
227229
- [:whale: nerdctl load](#whale-nerdctl-load)
228230
- [:whale: nerdctl save](#whale-nerdctl-save)
@@ -246,7 +248,7 @@ It does not necessarily mean that the corresponding features are missing in cont
246248
- [:whale: nerdctl volume inspect](#whale-nerdctl-volume-inspect)
247249
- [:whale: nerdctl volume rm](#whale-nerdctl-volume-rm)
248250
- [Namespace management](#namespace-management)
249-
- [:nerd_face: nerdctl namespace ls](#nerd_face-nerdctl-namespace-ls)
251+
- [:nerd_face: :window: nerdctl namespace ls](#nerd_face-nerdctl-namespace-ls)
250252
- [System](#system)
251253
- [:whale: nerdctl events](#whale-nerdctl-events)
252254
- [:whale: nerdctl info](#whale-nerdctl-info)
@@ -280,10 +282,10 @@ Run a command in a new container.
280282
Usage: `nerdctl run [OPTIONS] IMAGE [COMMAND] [ARG...]`
281283

282284
Basic flags:
283-
- :whale: `-i, --interactive`: Keep STDIN open even if not attached"
284-
- :whale: `-t, --tty`: Allocate a pseudo-TTY
285+
- :whale: :window: `-i, --interactive`: Keep STDIN open even if not attached"
286+
- :whale: :window: `-t, --tty`: Allocate a pseudo-TTY
285287
- :warning: WIP: currently `-t` requires `-i`, and conflicts with `-d`
286-
- :whale: `-d, --detach`: Run container in background and print container ID
288+
- :whale: :window: `-d, --detach`: Run container in background and print container ID
287289
- :whale: `--restart=(no|always)`: Restart policy to apply when a container exits
288290
- Default: "no"
289291
- :warning: No support for `on-failure` and `unless-stopped`
@@ -317,7 +319,7 @@ Cgroup flags:
317319
- :whale: `--device`: Add a host device to the container
318320

319321
User flags:
320-
- :whale: `-u, --user`: Username or UID (format: <name|uid>[:<group|gid>])
322+
- :whale: :window: `-u, --user`: Username or UID (format: <name|uid>[:<group|gid>])
321323

322324
Security flags:
323325
- :whale: `--security-opt seccomp=<PROFILE_JSON_FILE>`: specify custom seccomp profile
@@ -332,7 +334,7 @@ Runtime flags:
332334
- :whale: `--sysctl`: Sysctl options, e.g \"net.ipv4.ip_forward=1\"
333335

334336
Volume flags:
335-
- :whale: `-v, --volume`: Bind mount a volume
337+
- :whale: :window: `-v, --volume`: Bind mount a volume
336338
- :whale: `--tmpfs`: Mount a tmpfs directory
337339

338340
Rootfs flags:
@@ -341,16 +343,16 @@ Rootfs flags:
341343
Corresponds to Podman CLI.
342344

343345
Env flags:
344-
- :whale: `--entrypoint`: Overwrite the default ENTRYPOINT of the image
345-
- :whale: `-w, --workdir`: Working directory inside the container
346-
- :whale: `-e, --env`: Set environment variables
347-
- :whale: `--env-file`: Set environment variables from file
346+
- :whale: :window: `--entrypoint`: Overwrite the default ENTRYPOINT of the image
347+
- :whale: :window: `-w, --workdir`: Working directory inside the container
348+
- :whale: :window: `-e, --env`: Set environment variables
349+
- :whale: :window: `--env-file`: Set environment variables from file
348350

349351
Metadata flags:
350-
- :whale: `--name`: Assign a name to the container
351-
- :whale: `-l, --label`: Set meta data on a container
352-
- :whale: `--label-file`: Read in a line delimited file of labels
353-
- :whale: `--cidfile`: Write the container ID to the file
352+
- :whale: :window: `--name`: Assign a name to the container
353+
- :whale: :window: `-l, --label`: Set meta data on a container
354+
- :whale: :window: `--label-file`: Read in a line delimited file of labels
355+
- :whale: :window: `--cidfile`: Write the container ID to the file
354356
- :nerd_face: `--pidfile`: file path to write the task's pid. The CLI syntax conforms to Podman convention.
355357

356358
Shared memory flags:
@@ -480,7 +482,7 @@ Options:
480482

481483
</details>
482484

483-
### :whale: nerdctl exec
485+
### :whale: :window: nerdctl exec
484486
Run a command in a running container.
485487

486488
Usage: `nerdctl exec [OPTIONS] CONTAINER COMMAND [ARG...]`
@@ -511,7 +513,7 @@ Flags:
511513

512514
Unimplemented `docker ps` flags: `--filter`, `--last`, `--size`
513515

514-
### :whale: nerdctl inspect
516+
### :whale: :window: nerdctl inspect
515517
Display detailed information on one or more containers.
516518

517519
Usage: `nerdctl inspect [OPTIONS] NAME|ID [NAME|ID...]`
@@ -895,7 +897,7 @@ Usage: `nerdctl volume rm [OPTIONS] VOLUME [VOLUME...]`
895897

896898
## Namespace management
897899

898-
### :nerd_face: nerdctl namespace ls
900+
### :nerd_face: :window: nerdctl namespace ls
899901
List containerd namespaces such as "default", "moby", or "k8s.io".
900902

901903
Usage: `nerdctl namespace ls [OPTIONS]`
@@ -1039,13 +1041,13 @@ Unimplemented `docker-compose ps` (V1) flags: `--quiet`, `--services`, `--filter
10391041
Unimplemented `docker compose ps` (V2) flags: `--format`, `--status`
10401042

10411043
## Global flags
1042-
- :nerd_face: `-a`, `--address`: containerd address, optionally with "unix://" prefix
1044+
- :nerd_face: :window: `-a`, `--address`: containerd address, optionally with "unix://" prefix
10431045
- :whale: `-H`, `--host`: Docker-compatible alias for `-a`, `--address`
1044-
- :nerd_face: `-n`, `--namespace`: containerd namespace
1045-
- :nerd_face: `--snapshotter`: containerd snapshotter
1046-
- :nerd_face: `--cni-path`: CNI binary path (default: `/opt/cni/bin`) [`$CNI_PATH`]
1047-
- :nerd_face: `--cni-netconfpath`: CNI netconf path (default: `/etc/cni/net.d`) [`$NETCONFPATH`]
1048-
- :nerd_face: `--data-root`: nerdctl data root, e.g. "/var/lib/nerdctl"
1046+
- :nerd_face: :window: `-n`, `--namespace`: containerd namespace
1047+
- :nerd_face: :window: `--snapshotter`: containerd snapshotter
1048+
- :nerd_face: :window: `--cni-path`: CNI binary path (default: `/opt/cni/bin`) [`$CNI_PATH`]
1049+
- :nerd_face: :window: `--cni-netconfpath`: CNI netconf path (default: `/etc/cni/net.d`) [`$NETCONFPATH`]
1050+
- :nerd_face: :window: `--data-root`: nerdctl data root, e.g. "/var/lib/nerdctl"
10491051
- :nerd_face: `--cgroup-manager=(cgroupfs|systemd|none)`: cgroup manager
10501052
- Default: "systemd" on cgroup v2 (rootful & rootless), "cgroupfs" on v1 rootful, "none" on v1 rootless
10511053
- :nerd_face: `--insecure-registry`: skips verifying HTTPS certs, and allows falling back to plain HTTP

cmd/nerdctl/client.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func newClient(cmd *cobra.Command, opts ...containerd.ClientOpt) (*containerd.Cl
6363

6464
// getDataStore returns a string like "/var/lib/nerdctl/1935db59".
6565
// "1935db9" is from `$(echo -n "/run/containerd/containerd.sock" | sha256sum | cut -c1-8)``
66+
// on Windows it will return "%PROGRAMFILES%/nerdctl/1935db59"
6667
func getDataStore(cmd *cobra.Command) (string, error) {
6768
dataRoot, err := cmd.Flags().GetString("data-root")
6869
if err != nil {
@@ -91,12 +92,12 @@ func getAddrHash(addr string) (string, error) {
9192

9293
if runtime.GOOS != "windows" {
9394
addr = strings.TrimPrefix(addr, "unix://")
94-
}
9595

96-
var err error
97-
addr, err = filepath.EvalSymlinks(addr)
98-
if err != nil {
99-
return "", err
96+
var err error
97+
addr, err = filepath.EvalSymlinks(addr)
98+
if err != nil {
99+
return "", err
100+
}
100101
}
101102

102103
d := digest.SHA256.FromString(addr)

0 commit comments

Comments
 (0)