-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8955 from mheon/rename
Container Rename
- Loading branch information
Showing
15 changed files
with
459 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package containers | ||
|
||
import ( | ||
"github.com/containers/podman/v2/cmd/podman/common" | ||
"github.com/containers/podman/v2/cmd/podman/registry" | ||
"github.com/containers/podman/v2/pkg/domain/entities" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
renameDescription = "The podman rename command allows you to rename an existing container" | ||
renameCommand = &cobra.Command{ | ||
Use: "rename CONTAINER NAME", | ||
Short: "Rename an existing container", | ||
Long: renameDescription, | ||
RunE: rename, | ||
Args: cobra.ExactArgs(2), | ||
ValidArgsFunction: common.AutocompletePortCommand, | ||
Example: "podman rename containerA newName", | ||
} | ||
|
||
containerRenameCommand = &cobra.Command{ | ||
Use: renameCommand.Use, | ||
Short: renameCommand.Short, | ||
Long: renameCommand.Long, | ||
RunE: renameCommand.RunE, | ||
Args: renameCommand.Args, | ||
ValidArgsFunction: renameCommand.ValidArgsFunction, | ||
Example: "podman container rename containerA newName", | ||
} | ||
) | ||
|
||
func init() { | ||
// TODO: Once bindings are done, add this to TunnelMode | ||
registry.Commands = append(registry.Commands, registry.CliCommand{ | ||
Mode: []entities.EngineMode{entities.ABIMode}, | ||
Command: renameCommand, | ||
}) | ||
|
||
registry.Commands = append(registry.Commands, registry.CliCommand{ | ||
Mode: []entities.EngineMode{entities.ABIMode}, | ||
Command: containerRenameCommand, | ||
Parent: containerCmd, | ||
}) | ||
} | ||
|
||
func rename(cmd *cobra.Command, args []string) error { | ||
if len(args) > 2 { | ||
return errors.Errorf("must provide at least two arguments to rename") | ||
} | ||
renameOpts := entities.ContainerRenameOptions{ | ||
NewName: args[1], | ||
} | ||
return registry.ContainerEngine().ContainerRename(registry.GetContext(), args[0], renameOpts) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
% podman-rename(1) | ||
|
||
## NAME | ||
podman\-rename - Rename an existing container | ||
|
||
## SYNOPSIS | ||
**podman rename** *container* *newname* | ||
|
||
**podman container rename** *container* *newname* | ||
|
||
## DESCRIPTION | ||
Rename changes the name of an existing container. | ||
The old name will be freed, and will be available for use. | ||
This command can be run on containers in any state. | ||
However, running containers may not fully receive the effects until they are restarted - for example, a running container may still use the old name in its logs. | ||
At present, only containers are supported; pods and volumes cannot be renamed. | ||
|
||
## OPTIONS | ||
|
||
## EXAMPLES | ||
|
||
``` | ||
# Rename a container by name | ||
$ podman rename oldContainer aNewName | ||
``` | ||
|
||
``` | ||
# Rename a container by ID | ||
$ podman rename 717716c00a6b testcontainer | ||
``` | ||
|
||
``` | ||
# Use the container rename alias | ||
$ podman container rename 6e7514b47180 databaseCtr | ||
``` | ||
|
||
## SEE ALSO | ||
podman(1), podman-create(1), podman-run(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.