Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
songlinfeng
container-toolkit
Commits
cc9b79ca
Commit
cc9b79ca
authored
Nov 03, 2025
by
songlinfeng
Browse files
support rootless for podman
parent
3b3a28f3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
3 deletions
+80
-3
cmd/dtk-ctk/main.go
cmd/dtk-ctk/main.go
+2
-0
cmd/dtk-ctk/rootless/main.go
cmd/dtk-ctk/rootless/main.go
+76
-0
cmd/dtk-docker/main.go
cmd/dtk-docker/main.go
+2
-1
packaging/rpm/SPECS/dtk-container-toolkit.spec
packaging/rpm/SPECS/dtk-container-toolkit.spec
+0
-2
No files found.
cmd/dtk-ctk/main.go
View file @
cc9b79ca
...
...
@@ -9,6 +9,7 @@ import (
"dtk-container-toolkit/cmd/dtk-ctk/config"
"dtk-container-toolkit/cmd/dtk-ctk/hook"
"dtk-container-toolkit/cmd/dtk-ctk/runtime"
"dtk-container-toolkit/cmd/dtk-ctk/rootless"
"dtk-container-toolkit/internal/info"
"os"
...
...
@@ -71,6 +72,7 @@ func main() {
// Define the subcommands
c
.
Commands
=
[]
*
cli
.
Command
{
rootless
.
NewCommand
(
logger
),
runtime
.
NewCommand
(
logger
),
config
.
NewCommand
(
logger
),
hook
.
NewCommand
(
logger
),
...
...
cmd/dtk-ctk/rootless/main.go
0 → 100644
View file @
cc9b79ca
package
rootless
import
(
"dtk-container-toolkit/internal/logger"
"fmt"
"os"
"os/exec"
"github.com/urfave/cli/v2"
)
type
rootlessCommand
struct
{
logger
logger
.
Interface
}
type
options
struct
{
runtime
string
}
// NewCommand constructs a rootless command with the specified logger
func
NewCommand
(
logger
logger
.
Interface
)
*
cli
.
Command
{
c
:=
rootlessCommand
{
logger
:
logger
,
}
return
c
.
build
()
}
// build
func
(
m
rootlessCommand
)
build
()
*
cli
.
Command
{
// Create the 'rootless' command
opts
:=
options
{}
c
:=
cli
.
Command
{
Name
:
"rootless"
,
Usage
:
"Provide tools for configuring rootless container runtimes"
,
Action
:
func
(
ctx
*
cli
.
Context
)
error
{
return
run
(
ctx
,
&
opts
)
},
}
c
.
Flags
=
[]
cli
.
Flag
{
&
cli
.
StringFlag
{
Name
:
"runtime"
,
Aliases
:
[]
string
{
"r"
},
Usage
:
"docker or podman"
,
Value
:
"docker"
,
Destination
:
&
opts
.
runtime
,
},
}
return
&
c
}
func
run
(
c
*
cli
.
Context
,
opts
*
options
)
error
{
runtime
:=
opts
.
runtime
if
runtime
!=
"docker"
&&
runtime
!=
"podman"
{
return
fmt
.
Errorf
(
"invalid runtime %s"
,
runtime
)
}
_
,
err
:=
os
.
Stat
(
"/usr/bin/s"
+
runtime
)
if
os
.
IsNotExist
(
err
)
{
cmd
:=
exec
.
Command
(
"cp"
,
"/usr/bin/"
+
runtime
,
"/usr/bin/s"
+
runtime
)
cmd
.
Run
()
}
_
,
err
=
os
.
Stat
(
"/usr/bin/"
+
runtime
)
if
err
==
nil
{
os
.
Remove
(
"/usr/bin/"
+
runtime
)
}
cmd
:=
exec
.
Command
(
"cp"
,
"/usr/bin/dtk-docker"
,
"/usr/bin/"
+
runtime
)
err
=
cmd
.
Run
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to copy dtk-docker to /usr/bin/%s: %w"
,
runtime
,
err
)
}
return
nil
}
cmd/dtk-docker/main.go
View file @
cc9b79ca
...
...
@@ -44,6 +44,7 @@ func HasRunSubcommand(args [] string) bool {
}
func
main
()
{
runtime
:=
os
.
Args
[
0
]
args
:=
os
.
Args
[
1
:
]
newArgs
:=
[]
string
{}
if
!
HasRunSubcommand
(
args
)
{
...
...
@@ -61,7 +62,7 @@ func main() {
}
}
cmd
:=
exec
.
Command
(
"s
docker"
,
newArgs
...
)
cmd
:=
exec
.
Command
(
"s
"
+
runtime
,
newArgs
...
)
cmd
.
Stdin
=
os
.
Stdin
cmd
.
Stdout
=
os
.
Stdout
cmd
.
Stderr
=
os
.
Stderr
...
...
packaging/rpm/SPECS/dtk-container-toolkit.spec
View file @
cc9b79ca
...
...
@@ -32,8 +32,6 @@ install -m 755 -t %{buildroot}%{_bindir} dtk-docker
if [ ! -e %{_bindir}/nvidia-container-runtime-hook ]; then
# repairing lost file nvidia-container-runtime-hook
ln -sf %{_bindir}/dtk-container-runtime %{_bindir}/nvidia-container-runtime-hook
mv %{_bindir}/docker %{_bindir}/sdocker
mv %{_bindir}/dtk-docker %{_bindir}/docker
fi
# Generate the default config; If this file already exists no changes are made.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment