New in version 2014.1.0.
Note
The DockerIO integration is still in beta; the API is subject to change
You will need the 'docker-py' python package in your python installation running salt. The version of docker-py should support version 1.12 of docker remote API..
For now, you need docker-py 0.3.2
pip install docker-py==0.3.2
To push or pull you will need to be authenticated as the docker-py bindings require it
For this to happen, you will need to configure a mapping in the pillar representing your per URL authentication bits:
docker-registries:
registry_url:
email: foo@foo.com
password: s3cr3t
username: foo
You need at least an entry to the default docker index:
docker-registries:
https://index.docker.io/v1:
email: foo@foo.com
password: s3cr3t
username: foo
you can define multiple registries blocks for them to be aggregated, their id just must finish with -docker-registries:
ac-docker-registries:
https://index.bar.io/v1:
email: foo@foo.com
password: s3cr3t
username: foo
ab-docker-registries:
https://index.foo.io/v1:
email: foo@foo.com
password: s3cr3t
username: foo
Would be the equivalent to:
docker-registries:
https://index.bar.io/v1:
email: foo@foo.com
password: s3cr3t
username: foo
https://index.foo.io/v1:
email: foo@foo.com
password: s3cr3t
username: foo
You have those methods:
You have those methods:
You have those methods:
Build a docker image from a dockerfile or an URL
You can either:
- give the url/branch/docker_dir
- give a path on the file system
CLI Example:
salt '*' docker.build
Commit a container (promotes it to an image)
CLI Example:
salt '*' docker.commit <container id>
Create a new container
list of volumes mapping:
(['/mountpoint/in/container:/guest/foo',
'/same/path/mounted/point'])
EG:
salt-call docker.create_container o/ubuntu volumes="['/s','/m:/f']"
CLI Example:
salt '*' docker.create_container <image>
Get container diffs
CLI Example:
salt '*' docker.diff <container id>
Check if a given container exists
Parameters: | container (string) -- Container id |
---|---|
Return type: | boolean: |
CLI Example:
salt '*' docker.exists <container>
Export a container to a file
CLI Example:
salt '*' docker.export <container id>
Get the container rootfs path
CLI Example:
salt '*' docker.get_container_root <container id>
Get a list of mappings representing all containers
Returns a mapping of something which looks like container
CLI Example:
salt '*' docker.get_containers
salt '*' docker.get_containers host=True
List docker images
Parameters: |
|
---|---|
Return type: | dict |
Returns: | A status message with the command output |
CLI Example:
salt '*' docker.get_images [name] [quiet=True|False] [all=True|False]
Import content from a local tarball or a URL to a docker image
Parameters: |
|
---|
CLI Example:
salt '*' docker.import_image <src> <repo> [tag]
Get the version information about docker
Return type: | dict |
---|---|
Returns: | A status message with the command output |
CLI Example:
salt '*' docker.info
Get container information. This is similar to the docker inspect command.
Parameters: | container (string) -- The id of the container to inspect |
---|---|
Return type: | dict |
Returns: | A status message with the command output |
CLI Example:
salt '*' docker.inspect_container <container>
Inspect the status of an image and return relative data
CLI Example:
salt '*' docker.inspect_image <image>
Is this container running
Return boolean
CLI Example:
salt '*' docker.is_running <container_id>
Kill a running container
Parameters: | container (string) -- The container id to kill |
---|---|
Return type: | dict |
Returns: | A status message with the command output
ex: {'id': 'abcdef123456789',
'status': True}
|
CLI Example:
salt '*' docker.kill <container id>
Wrapper to the docker.py login method, does not do much yet
CLI Example:
salt '*' docker.login <container_id>
Return logs for a specified container
CLI Example:
salt '*' docker.logs <container id>
Private/Public for a specific port mapping allocation information This method is broken on docker-py side Just use the result of inspect to mangle port allocation
CLI Example:
salt '*' docker.port <container id>
Pulls an image from any registry. See above documentation for how to configure authenticated access.
Parameters: |
|
---|---|
Return type: | dict |
Returns: | A status message with the command output Example: ----------
comment:
Image NAME was pulled (ID
id:
None
out:
----------
- id:
2c80228370c9
- status:
Download complete
----------
- id:
2c80228370c9
- progress:
[=========================> ]
- status:
Downloading
----------
- id:
2c80228370c9
- status
Pulling image (latest) from foo/ubuntubox
----------
- status:
Pulling repository foo/ubuntubox
status:
True
|
CLI Example:
salt '*' docker.pull <repository> [tag]
Pushes an image from any registry See this top level documentation to know how to configure authenticated access
[registryurl://]REPOSITORY_NAME_image eg:
index.docker.io:MyRepo/image
superaddress.cdn:MyRepo/image
MyRepo/image
CLI Example:
salt '*' docker.push <repo>
Removes a container from a docker installation
Return True or False in the status mapping and also any information about docker in status['out']
CLI Example:
salt '*' docker.remove_container <container_id>
Remove an image from a system.
Parameters: | image (string) -- The image to remove |
---|---|
Return type: | string |
Returns: | A status message. |
CLI Example:
salt '*' docker.remove_image <image>
Restart a running container
Parameters: |
|
---|---|
Return type: | dict |
Returns: | A status message with the command output ex: {'id': 'abcdef123456789',
'status': True}
|
CLI Example:
salt '*' docker.restart <container id>
Wrapper for cmdmod.retcode inside a container context
The return is a bit different as we use the docker struct, The output of the command is in 'out' The result is false if command failed
CLI Example:
salt '*' docker.retcode <container id> 'ls -l /etc'
Wrapper for cmdmod.run inside a container context
The return is a bit different as we use the docker struct, The output of the command is in 'out' The result is always True
CLI Example:
salt '*' docker.run <container id> 'ls -l /etc'
Wrapper for cmdmod.run_all inside a container context
The return is a bit different as we use the docker struct, The output of the command is in 'out' The result if false if command failed
CLI Example:
salt '*' docker.run_all <container id> 'ls -l /etc'
Wrapper for cmdmod.run_stderr inside a container context
The return is a bit different as we use the docker struct, The output of the command is in 'out' The result is always True
CLI Example:
salt '*' docker.run_stderr <container id> 'ls -l /etc'
Wrapper for cmdmod.run_stdout inside a container context
The return is a bit different as we use the docker struct, The output of the command is in 'out' The result is always True
CLI Example:
salt '*' docker.run_stdout <container id> 'ls -l /etc'
Same usage as cmd.script but running inside a container context
CLI Example:
salt '*' docker.script <container id> salt://docker_script.py
Same usage as cmd.script_retcode but running inside a container context
CLI Example:
salt '*' docker.script_retcode <container id> salt://docker_script.py
Search for an image on the registry
Parameters: | term (string) -- The search keyword to query |
---|
CLI Example:
salt '*' docker.search <term>
Restart the specified container
CLI Example:
salt '*' docker.start <container_id>
Stop a running container
Parameters: |
|
---|---|
Return type: | dict |
Returns: | A status message with the command output ex: {'id': 'abcdef123456789',
'status': True}
|
CLI Example:
salt '*' docker.stop <container id>
Tag an image into a repository
Parameters: |
|
---|
CLI Example:
salt '*' docker.tag <image> <repository> [tag] [force=(True|False)]
Run the docker top command on a specific container
Returns in the 'out' status mapping a mapping for those running processes:
{
'Titles': top titles list,
'processes': list of ordered by
titles processes information,
'mprocesses': list of mappings processes information
constructed above the upon information
}
CLI Example:
salt '*' docker.top <container_id>
Get docker version
CLI Example:
salt '*' docker.version
Blocking wait for a container exit gracefully without timeout killing it
CLI Example:
salt '*' docker.wait <container id>
Current Salt release: 2014.1.6
Docs for previous releases on salt.rtfd.org.