Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
moby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
emulab
moby
Commits
4099a313
Commit
4099a313
authored
11 years ago
by
Guillaume J. Charmes
Browse files
Options
Downloads
Patches
Plain Diff
Implement the -volumes-from in order to mount volumes from an other container
parent
6fb495bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
container.go
+20
-0
20 additions, 0 deletions
container.go
with
20 additions
and
0 deletions
container.go
+
20
−
0
View file @
4099a313
...
...
@@ -68,6 +68,7 @@ type Config struct {
Dns
[]
string
Image
string
// Name of the image as it was passed by the operator (eg. could be symbolic)
Volumes
map
[
string
]
struct
{}
VolumesFrom
string
}
func
ParseRun
(
args
[]
string
,
stdout
io
.
Writer
,
capabilities
*
Capabilities
)
(
*
Config
,
error
)
{
...
...
@@ -102,6 +103,8 @@ func ParseRun(args []string, stdout io.Writer, capabilities *Capabilities) (*Con
flVolumes
:=
NewPathOpts
()
cmd
.
Var
(
flVolumes
,
"v"
,
"Attach a data volume"
)
flVolumesFrom
:=
cmd
.
String
(
"volumes-from"
,
""
,
"Mount volumes from the specified container"
)
if
err
:=
cmd
.
Parse
(
args
);
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -142,6 +145,7 @@ func ParseRun(args []string, stdout io.Writer, capabilities *Capabilities) (*Con
Dns
:
flDns
,
Image
:
image
,
Volumes
:
flVolumes
,
VolumesFrom
:
*
flVolumesFrom
,
}
if
*
flMemory
>
0
&&
!
capabilities
.
SwapLimit
{
...
...
@@ -414,6 +418,22 @@ func (container *Container) Start() error {
}
}
if
container
.
Config
.
VolumesFrom
!=
""
{
c
:=
container
.
runtime
.
Get
(
container
.
Config
.
VolumesFrom
)
if
c
==
nil
{
return
fmt
.
Errorf
(
"Container %s not found. Impossible to mount its volumes"
)
}
for
volPath
,
id
:=
range
c
.
Volumes
{
if
_
,
exists
:=
container
.
Volumes
[
volPath
];
exists
{
return
fmt
.
Errorf
(
"The requested volume %s overlap one of the volume of the container %s"
,
volPath
,
c
.
Id
)
}
if
err
:=
os
.
MkdirAll
(
path
.
Join
(
container
.
RootfsPath
(),
volPath
),
0755
);
err
!=
nil
{
return
nil
}
container
.
Volumes
[
volPath
]
=
id
}
}
if
err
:=
container
.
generateLXCConfig
();
err
!=
nil
{
return
err
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment