Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
e8768785
Commit
e8768785
authored
Jan 19, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
website: add docs for docker-import and docker-push
parent
c18b74e9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
114 additions
and
11 deletions
+114
-11
builder/docker/driver.go
builder/docker/driver.go
+3
-0
builder/docker/driver_docker.go
builder/docker/driver_docker.go
+5
-0
builder/docker/driver_mock.go
builder/docker/driver_mock.go
+10
-0
website/source/docs/builders/docker.html.markdown
website/source/docs/builders/docker.html.markdown
+22
-11
website/source/docs/post-processors/docker-import.html.markdown
...e/source/docs/post-processors/docker-import.html.markdown
+44
-0
website/source/docs/post-processors/docker-push.html.markdown
...ite/source/docs/post-processors/docker-push.html.markdown
+28
-0
website/source/layouts/docs.erb
website/source/layouts/docs.erb
+2
-0
No files found.
builder/docker/driver.go
View file @
e8768785
...
...
@@ -20,6 +20,9 @@ type Driver interface {
// Pull should pull down the given image.
Pull
(
image
string
)
error
// Push pushes an image to a Docker index/registry.
Push
(
name
string
)
error
// StartContainer starts a container and returns the ID for that container,
// along with a potential error.
StartContainer
(
*
ContainerConfig
)
(
string
,
error
)
...
...
builder/docker/driver_docker.go
View file @
e8768785
...
...
@@ -93,6 +93,11 @@ func (d *DockerDriver) Pull(image string) error {
return
runAndStream
(
cmd
,
d
.
Ui
)
}
func
(
d
*
DockerDriver
)
Push
(
name
string
)
error
{
cmd
:=
exec
.
Command
(
"docker"
,
"push"
,
name
)
return
runAndStream
(
cmd
,
d
.
Ui
)
}
func
(
d
*
DockerDriver
)
StartContainer
(
config
*
ContainerConfig
)
(
string
,
error
)
{
// Build up the template data
var
tplData
startContainerTemplate
...
...
builder/docker/driver_mock.go
View file @
e8768785
...
...
@@ -16,6 +16,10 @@ type MockDriver struct {
ImportId
string
ImportErr
error
PushCalled
bool
PushName
string
PushErr
error
ExportReader
io
.
Reader
ExportError
error
PullError
error
...
...
@@ -68,6 +72,12 @@ func (d *MockDriver) Pull(image string) error {
return
d
.
PullError
}
func
(
d
*
MockDriver
)
Push
(
name
string
)
error
{
d
.
PushCalled
=
true
d
.
PushName
=
name
return
d
.
PushErr
}
func
(
d
*
MockDriver
)
StartContainer
(
config
*
ContainerConfig
)
(
string
,
error
)
{
d
.
StartCalled
=
true
d
.
StartConfig
=
config
...
...
website/source/docs/builders/docker.html.markdown
View file @
e8768785
...
...
@@ -64,15 +64,31 @@ Optional:
`["run", "-d", "-i", "-t", "-v", "{{.Volumes}}", "{{.Image}}", "/bin/bash"]`
.
As you can see, you have a couple template variables to customize, as well.
## Using the
generated a
rtifact
## Using the
A
rtifact
Once the tar artifact has been generated, you will likely want to import, tag,
and push it to a container repository. Until packer supports management of the
docker image metadata, this process is manual. For example, the following will
import
`mycontainer-123456789.tar`
to the repository
`registry.mydomain.com/mycontainer`
, tagged with
`latest`
:
and push it to a container repository. Packer can do this for you automatically
with the
[
docker-import
](
/docs/post-processors/docker-import.html
)
and
[
docker-push
](
/docs/post-processors/docker-push.html
)
post-processors.
sudo docker import - registry.mydomain.com/mycontainer:latest < mycontainer-123456789.tar
The example below shows a full configuration that would import and push
the created image:
<pre
class=
"prettyprint"
>
{
"post-processors": [
[
{ "type": "docker-import", "repository": "mitchellh/packer", "tag": "0.7" },
"docker-push"
]
]
}
</pre>
If you want to do this manually, however, perhaps from a script, you can
import the image using the process below:
docker import - registry.mydomain.com/mycontainer:latest < artifact.tar
You can then add additional tags and push the image as usual with
`docker tag`
and
`docker push`
, respectively.
...
...
@@ -103,8 +119,3 @@ by Packer in the future:
volumes, and other metadata. Packer builds a raw Docker container image
that has none of this metadata. You can pass in much of this metadata
at runtime with
`docker run`
.
*
Images made without dockerfiles are missing critical metadata that
make them easily pushable to the Docker registry. You can work around
this by using a metadata-only Dockerfile with the exported image and
building that. A future Packer version will automatically do this for you.
website/source/docs/post-processors/docker-import.html.markdown
0 → 100644
View file @
e8768785
---
layout
:
"
docs"
page_title
:
"
docker-import
Post-Processor"
---
# Docker Import Post-Processor
Type:
`docker-import`
The Docker import post-processor takes an artifact from the
[
docker builder
](
/docs/builders/docker.html
)
and imports it with Docker
locally. This allows you to apply a repository and tag to the image
and lets you use the other Docker post-processors such as
[
docker-push
](
/docs/post-processors/docker-push.html
)
to push the image
to a registry.
## Configuration
The configuration for this post-processor is extremely simple. At least
a repository is required. The tag is optional.
*
`repository`
(string) - The repository of the imported image.
*
`tag`
(string) - The tag for the imported image. By default this is not
set.
## Example
An example is shown below, showing only the post-processor configuration:
<pre
class=
"prettyprint"
>
{
"type": "docker-import",
"repository": "mitchellh/packer",
"tag": "0.7"
}
</pre>
This example would take the image created by the Docker builder
and import it into the local Docker process with a name of
`mitchellh/packer:0.7`
.
Following this, you can use the
[
docker-push
](
/docs/post-processors/docker-push.html
)
post-processor to push it to a registry, if you want.
website/source/docs/post-processors/docker-push.html.markdown
0 → 100644
View file @
e8768785
---
layout
:
"
docs"
page_title
:
"
Docker
Push
Post-Processor"
---
# Docker Push Post-Processor
Type:
`docker-push`
The Docker push post-processor takes an artifact from the
[
docker-import
](
/docs/post-processors/docker-import.html
)
post-processor
and pushes it to a Docker registry.
<div
class=
"alert alert-info alert-block"
>
<strong>
Before you use this,
</strong>
you must manually
<code>
docker login
</code>
to the proper repository. A future version of Packer will automate this
for you, but for now you must manually do this.
</div>
## Configuration
This post-processor has no configuration! Simply add it to your chain
of post-processors and the image will be uploaded.
## Example
For an example of using docker-push, see the section on using
generated artifacts from the
[
docker builder
](
/docs/builders/docker.html
)
.
website/source/layouts/docs.erb
View file @
e8768785
...
...
@@ -54,6 +54,8 @@
<ul>
<li><h4>
Post-Processors
</h4></li>
<li><a
href=
"/docs/post-processors/docker-import.html"
>
docker-import
</a></li>
<li><a
href=
"/docs/post-processors/docker-push.html"
>
docker-push
</a></li>
<li><a
href=
"/docs/post-processors/vagrant.html"
>
Vagrant
</a></li>
<li><a
href=
"/docs/post-processors/vsphere.html"
>
vSphere
</a></li>
</ul>
...
...
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