> For the complete CircleCI developer hub index, see [llms.txt](https://circleci.com/developer/llms.txt)

# circleci/docker-publish

Build and publish Docker images to container registries. Note: ths orb
is no longer actively maintained. Its commands, jobs, executors, and
examples have been moved into the `circleci/docker` orb, where all
future development on them will occur:
http://circleci.com/orbs/registry/orb/circleci/docker
https://github.com/CircleCI-Public/docker-orb


## Commands

### check

Sanity check to make sure you can build a docker image.

  * check that $DOCKER_LOGIN and $DOCKER_PASSWORD environment variables are set
  * run docker login to ensure that you can push the built image


| Parameter | Type | Default | Description |
|---|---|---|---|
| `registry` | string | docker.io | Name of registry to use. Defaults to docker.io. |

### build

Builds and Tags a Docker Image.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `dockerfile` | string | Dockerfile | Name of dockerfile to use. Defaults to Dockerfile. |
| `path` | string | . | Path to the directory containing your Dockerfile and build context. Defaults to . (working directory). |
| `image` | string | $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME | Name of image to create. Defaults to a combination of $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME. |
| `tag` | string | $CIRCLE_SHA1 | Value for tag to use. Defaults to $CIRCLE_SHA1. |
| `registry` | string | docker.io | Name of registry to use. Defaults to docker.io. |
| `extra_build_args` | string |  | Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build
 |

### deploy

Deploy docker image to a registry.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `registry` | string | docker.io | Name of registry to use. Defaults to docker.io. |
| `image` | string | $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME | Name of image to create. Defaults to a combination of $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME. |

## Jobs

### publish

Check, build, and optionally deploy a Docker image.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `dockerfile` | string | Dockerfile | Name of dockerfile to use. Defaults to Dockerfile. |
| `path` | string | . | Path to the directory containing your Dockerfile and build context. Defaults to . (working directory). |
| `image` | string | $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME | Name of image to create. Defaults to a combination of $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME. |
| `tag` | string | $CIRCLE_SHA1 | Value for tag to use. Defaults to $CIRCLE_SHA1. |
| `registry` | string | docker.io | Name of registry to use. Defaults to docker.io. |
| `extra_build_args` | string |  | Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build
 |
| `after_checkout` | steps |  | Optional steps to run after checking out the code. |
| `before_build` | steps |  | Optional steps to run before building the docker image. |
| `after_build` | steps |  | Optional steps to run after building the docker image. |
| `deploy` | boolean | true | Whether or not to push image to a registry. |

## Executors

### docker

The docker container to use when running docker-publish builds

## Examples

### standard_build_and_push

A standard docker workflow, where you are building an image with a
Dockerfile in the root of your repository, naming the image to be the
same name as your repository, and then pushing to the default docker
registry (at docker.io).


```yaml
version: 2.1
orbs:
  docker-publish: circleci/docker-publish@1.0.0
workflows:
  build_and_publish_docker_image:
    jobs:
      - docker-publish/publish
```

### custom_name_and_tag

Build and Deploy docker image with a custom name and tag.

```yaml
version: 2.1
orbs:
  docker-publish: circleci/docker-publish@1.0.0
workflows:
  build_and_publish_docker_image:
    jobs:
      - docker-publish/publish:
          image: my/image
          tag: my_tag
```

### custom_registry_and_dockerfile

Build and Deploy docker image with a non standard Dockerfile and to a
custom registry.


```yaml
version: 2.1
orbs:
  docker-publish: circleci/docker-publish@1.0.0
workflows:
  build_and_publish_docker_image:
    jobs:
      - docker-publish/publish:
          registry: my.docker.registry
          dockerfile: path/to/MyDockerFile
```

### life_cycle_hooks

Build and deploy a docker image with custom lifecycle hooks; before
checking out the code from the VCS repository, before building the
docker image, and after building the docker image.


```yaml
version: 2.1
orbs:
  docker-publish: circleci/docker-publish@1.0.0
workflows:
  docker_with_lifecycle:
    jobs:
      - docker-publish/publish:
          after_checkout:
            - run:
                name: Do this after checkout.
                command: echo "Did this after checkout"
          before_build:
            - run:
                name: Do this before the build.
                command: echo "Did this before the build"
          after_build:
            - run:
                name: Do this after the build.
                command: echo "Did this after the build"
```

### build_without_publishing_job

Build, but don't publish, an image using the publish job.


```yaml
version: 2.1
orbs:
  docker-publish: circleci/docker-publish@1.0.0
workflows:
  build_without_publishing:
    jobs:
      - docker-publish/publish:
          deploy: false
```

### build_without_publishing_commands

Build, but don't publish, an image using the check and build jobs.


```yaml
version: 2.1
orbs:
  docker-publish: circleci/docker-publish@1.0.0
jobs:
  check_and_build_only:
    executor: docker-publish/docker
    steps:
      - checkout
      - setup_remote_docker
      - docker-publish/check
      - docker-publish/build
workflows:
  build_without_publishing:
    jobs:
      - check_and_build_only
```

### with_extra_build_args

Build/publish a docker image with extra build arguments


```yaml
version: 2.1
orbs:
  docker-publish: circleci/docker-publish@1.0.0
workflows:
  extra_build_args:
    jobs:
      - docker-publish/publish:
          extra_build_args: '--build-arg FOO=bar --build-arg BAZ=qux'
```