# salt.states.dockerio

## Management of dockers

Note

This state module is beta; the API is subject to change and no promise as to performance or functionality is yet present

### Available Functions

- built

      corp/mysuperdocker_img:
          docker.build:
              - path: /path/to/dir/container/Dockerfile

- pulled

      ubuntu:
        docker.pulled

- installed

      mysuperdocker:
          docker.installed:
              - hostname: superdocker
              - image: corp/mysuperdocker_img

- absent

      mys_old_uperdocker:
         docker.absent

- run

      /finish-install.sh:
          docker.run:
              - container: mysuperdocker
              - unless: grep -q something /var/log/foo
              - docker_unless: grep -q done /install_log

Note: The docker Modules can't be called docker as it would conflict with the underlying binding modules: docker-py

`salt.states.dockerio.` `absent`(name)

  Container should be absent or will be killed, destroyed, and eventually we will remove the grain matching

  You can match by either a state id or a container id

  name:
    Either the state_id or container id

`salt.states.dockerio.` `built`(name, path=None, quiet=False, nocache=False, rm=True, force=False, *args, **kwargs)

  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
  name
    Tag of the image
  path
    URL or path in the filesystem to the dockerfile

`salt.states.dockerio.` `installed`(name, image, command='/sbin/init', hostname=None, user=None, detach=True, stdin_open=False, tty=False, mem_limit=0, ports=None, environment=None, dns=None, volumes=None, volumes_from=None, force=False, started=True, *args, **kwargs)

  Build a new container from an image

  name
    this name will be stored in grain for not reinstalling again and again the same container
  image
    the image from which to build this container
  path
    Path in the filesystem to the dockerfile
  environment
    Environment variables for the container, either
      - a mapping of key, values
      - a list of mappings of key values
  ports
    List of ports definitions, either:
      - a port to map
      - a mapping of mapping portInHost : PortInContainer
  volumes
    List of volumes mappings definitions, either:
      - a volume inside the host which is mounted as the same location in the container
      - a mapping mountpointInContainer:MountpointinHost
  started
    Is the container running (default: true)

  For other parameters, please look at the module documentation

  You can create it either by specifying :

  > - an image
  > - an absolute path on the filesystem

  This mean that you need one of those two parameters:

`salt.states.dockerio.` `present`(name)

  Container should be present or this state will fail

  You can match by either a state id or a container id

  name:
    Either the state_id or container id

`salt.states.dockerio.` `pulled`(name, force=False, *args, **kwargs)

  Pull an image from a docker registry

  Remember to look on the execution module to see how to ident yourself with a registry

  name
    Tag of the image
  force
    pull even if the image is already pulled

`salt.states.dockerio.` `run`(name, cid=None, hostname=None, stateful=False, onlyif=None, unless=None, docked_onlyif=None, docked_unless=None, *args, **kwargs)

  Run a command in a specific container

  XXX: TODO: IMPLEMENT

  You can match by either name or hostname

  name
    command to run in the docker
  cid
    Container id
  state_id
    state_id
  stateful
    stateful mode
  onlyif
    Only execute cmd if statement on the host return 0
  unless
    Do not execute cmd if statement on the host return 0
  docked_onlyif
    Same as onlyif but executed in the context of the docker
  docked_unless
    Same as unless but executed in the context of the docker

`salt.states.dockerio.` `script`(name, cid=None, hostname=None, state_id=None, stateful=False, onlyif=None, unless=None, docked_onlyif=None, docked_unless=None, *args, **kwargs)

  Run a command in a specific container

  XXX: TODO: IMPLEMENT

  You can match by either name or hostname

  name
    command to run in the docker
  cid
    Container id
  state_id
    State Id
  stateful
    stateful mode
  onlyif
    Only execute cmd if statement on the host return 0
  unless
    Do not execute cmd if statement on the host return 0
  docked_onlyif
    Same as onlyif but executed in the context of the docker
  docked_unless
    Same as unless but executed in the context of the docker

Current Salt release: 0.17.1

### Table Of Contents

- salt.states.dockerio
  - Management of dockers
    - Available Functions

#### Previous topic

salt.states.disk

#### Next topic

salt.states.eselect

### Quick search

Enter search terms or a module, class or function name.

### Upcoming SaltStack Events

My conferences on Lanyrd