Commit Graph

45 Commits

Author SHA1 Message Date
Fu Wei
ab963e1cc1
Merge pull request #5063 from Iceber/fix-with-dev-shm-size
oci: fix WithDevShmSize
2021-05-06 23:48:04 +08:00
Akihiro Suda
8ba8533bde
pkg/cri/opts.WithoutRunMount -> oci.WithoutRunMount
Move `pkg/cri/opts.WithoutRunMount` function to `oci.WithoutRunMount`
so that it can be used without dependency on CRI.

Also add `oci.WithoutMounts(dests ...string)` for generality.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-04-07 21:25:36 +09:00
Iceber Gu
b592a4c1ec
oci: fix WithDevShmSize
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2021-03-17 13:43:58 +08:00
Brian Goff
7776e5ef2a Support adding devices by dir
This enables cases where devices exist in a subdirectory of /dev,
particularly where those device names are not portable across machines,
which makes it problematic to specify from a runtime such as cri.

Added this to `ctr` as well so I could test that the code at least
works.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-03-15 16:42:23 +00:00
Derek McGowan
35eeb24a17
Fix exported comments enforcer in CI
Add comments where missing and fix incorrect comments

Signed-off-by: Derek McGowan <derek@mcg.dev>
2021-03-12 08:47:05 -08:00
Iceber Gu
f7f6aabfff oci: fix superfluous slice operations
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2021-02-26 02:35:25 +08:00
Akihiro Suda
a2d1a8a865
oci.WithPrivileged: set the current caps, not the known caps
This change is needed for running the latest containerd inside Docker
that is not aware of the recently added caps (BPF, PERFMON, CHECKPOINT_RESTORE).

Without this change, containerd inside Docker fails to run containers with
"apply caps: operation not permitted" error.

See kubernetes-sigs/kind 2058

NOTE: The caller process of this function is now assumed to be as
privileged as possible.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-02-10 17:14:17 +09:00
Akihiro Suda
8a57d70a50
oci: expose getUserFromPath and getGIDFromPath
These functions are planned to be used for implementing `nerdctl exec --user`.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-12-14 21:53:17 +09:00
Kir Kolyshkin
6e638ad27a Nit: fix use of bufio.Scanner.Err
The Err() method should be called after the Scan() loop, not inside it.

Found by: git grep -A3 -F '.Scan()'

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-11 19:36:21 -07:00
Michael Crosby
a3ca8a0dfc Add linux resource oci.SpecOpts
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2020-03-05 13:02:10 -05:00
Jie Hao Liao
51a6813c06 Split uid and gid user ns remapping in oci
Signed-off-by: Jie Hao Liao <liaojh1998@gmail.com>
2019-12-10 03:07:50 -06:00
Michael Crosby
a6d3f4d30b
Add device opts to ctr --privileged
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-10-10 14:23:59 -04:00
Michael Crosby
25947db049 Add support for spec generation with host devices
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-10-07 10:37:58 -04:00
Michael Crosby
20d3fae3db Add Opt for modifying shm size
Closes #3654

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-09-18 10:20:36 -04:00
Michael Crosby
fa11147e5f Add --env-file to ctr
Closes #3517

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-09-06 16:25:02 -04:00
Phil Estes
bc692cc59d
Use default UNIX env when image has no environment
Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2019-08-29 10:16:24 -04:00
chentanjun
92a5b08a68 fix-grammar-mistake
Signed-off-by: chentanjun <2799194073@qq.com>
2019-08-28 16:10:08 +08:00
Michael Crosby
7379fa6631 Remove the process default ENV
With the change in #3542 it breaks $PATH handling for images becuase our
default spec always sets a PATH on the process's .Env.

This removes the default and adds an Opt to add this back.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-08-19 18:18:58 +00:00
Yangyang
1c30d4d04c bugfix: override image.Env with process.Env, rather than be contrary
Signed-off-by: Yangyang <1032120121@163.com>
2019-08-16 18:53:07 +08:00
Michael Crosby
725d3ad8cb Add --device flag to ctr
Closes #3066

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-07-18 18:51:05 +00:00
Michael Crosby
dca17853d8 Add WithLinuxDevices Opt
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-07-18 17:11:14 +00:00
Lantao Liu
808b223536 Fix race and panic.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-03-28 01:27:13 -07:00
Michael Crosby
388c8a1760 Fastpath opt and ExecProcess loading
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-03-22 12:08:43 -04:00
Michael Crosby
bdd84abf05 Add additional capability handling opts
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-03-15 12:31:41 -04:00
Michael Crosby
84a24711e8 Add runc.v2 multi-shim
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-02-21 11:09:46 -05:00
akolomentsev
f2344db40a do not mutate defaults in replaceOrAppendEnvValues
Signed-off-by: Andrey Kolomentsev <andrey.kolomentsev@docker.com>
2018-12-19 16:38:22 -08:00
akolomentsev
da9471fb11 fix oci.WithImageConfigArgs for windows
Signed-off-by: Andrey Kolomentsev <andrey.kolomentsev@docker.com>
2018-12-19 12:25:36 -08:00
Justin Terry (VM)
7ac221e8d7 Adding ctr memory and cpu flags
Adds ctr run --memory-limit for all platforms.
Adds ctr run --cpu-count for Windows platforms.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-12-10 13:31:59 -08:00
Justin Terry (VM)
223acbca2a Skip AdditionalGID's for LCOW oci spec
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-10-03 10:43:29 -07:00
Justin Terry (VM)
547bb94e4b Fix ctr run for Windows containers
1. Fixes bugs in ctr run that were introduced by 1d9b969
2. Adds support for the --isolated flag that runs Windows HyperV
cotainers instead of process isolated containers on Windows.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-09-20 14:28:36 -07:00
Derek McGowan
9faeea1e5e
Merge pull request #2649 from estesp/nonewpriv-flag
Add flag to ctr for running with "NoNewPrivileges: false"
2018-09-19 11:17:05 -07:00
Phil Estes
13931e41d6
Add additional GIDs by default if they exist in /etc/group
If we are using an image config, we should by default add any additional
GIDs that are found from reading /etc/group, even if the default user is
root.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2018-09-14 13:28:50 -04:00
Phil Estes
c28ce39cea
Add flag to ctr for running with NoNewPrivileges: false
Add flag and With-helper to set NoNewPrivileges to false since it is on
by default in the default UNIX spec for containerd, but off by default
in Docker and CRI plugin use. This allows for easy testing with it off
for comparison.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2018-09-14 11:03:58 -04:00
Lantao Liu
178db322b3 Support uid in WithAdditionalGIDs.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-09-13 10:51:14 -07:00
Phil Estes
78e61af47a
Add With-helper for supplemental gid support
Can be used to conform to Docker engine behavior of adding additional
GIDs to spec when found in /etc/group of image filesystem

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2018-09-11 23:01:15 -04:00
Justin Terry (VM)
ef910311e8 Add a Windows section for Linux oci on LCOW
When creating a default OCI spec on Windows that is targeting the LCOW
platform it needs to contain a Windows section as well. This adds the
Windows section by default. It also protects against this case for all
OCI creation that doesnt use the OCI package in the runhcs-shim.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-09-06 11:05:45 -07:00
Justin Terry (VM)
c818a6b13d Merges the oci package for Linux and Windows
On Windows we need to be able to create both Linux and Windows OCI spec
files by default to support WCOW and LCOW scenarios. This merges the
compile time differences into runtime differences between the two based
on the spec and platform the user sets.

It maintains the old behavior with Default specs resulting in the
platform default the binary is compiled for.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-08-30 09:46:04 -07:00
Stephen Day
2a1bd7414b
oci: introduce WithSpecFromFile combinator
We introduce a WithSpecFromFile option combinator to allow creation
simpler creation of OCI specs from a file name. Often used as the first
option in a `SpecOpts` slice, it simplifies choosing between a local
file and the built-in default.

The code in `ctr run` has been updated to use the new option, with out
changing the order of operations or functionality present there.

Signed-off-by: Stephen Day <stephen.day@getcruise.com>
2018-07-27 14:25:42 -07:00
Michael Crosby
62e22a9fe7 Type alias spec in oci package
This allows Go to build third party packages correctly without vendoring
issues what want to create their own SpecOpts.

Fixes #2289

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-05-17 09:18:46 -04:00
Justin Cormack
062c3a00ef
Add a WithPrivileged OCI constructor and the options needed to build it
Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2018-04-04 13:25:34 +01:00
Justin Cormack
0ee2f35e43
Consistently add empty types where they are nil in spec
In a few places we check for nil types when modifying a spec,
but in many cases we do not so we could get a panic if the
passed in type was not filled. Because the generated spec is
filled we will not notice this but users may get unexpected
panics.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2018-04-03 14:44:23 +01:00
Kunal Kushwaha
b12c3215a0 Licence header added
Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-02-19 10:32:26 +09:00
Justin Cormack
eab5d87af1 Fix typo in variable name
Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2018-02-13 15:06:49 +00:00
Paul Knopf
b4c3cd7640
Add WithEnv and WithMount oci options
Signed-off-by: Paul Knopf <pauldotknopf@gmail.com>
2018-01-22 16:35:31 -05:00
Daniel Nephin
081f8c7ce0 oci package passing tests
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-27 16:14:43 -05:00