# Feeding meta-data to a docker plugin command

**URL:** https://forum.buildkite.community/t/feeding-meta-data-to-a-docker-plugin-command/2575
**Category:** General
**Created:** [February 24, 2023, 8:43pm UTC](https://forum.buildkite.community/t/feeding-meta-data-to-a-docker-plugin-command/2575 "2023-02-24T20:43:08Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![masper](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@masper](https://forum.buildkite.community/u/masper)
#### Post date: [February 24, 2023, 8:43pm UTC](https://forum.buildkite.community/t/feeding-meta-data-to-a-docker-plugin-command/2575/1 "2023-02-24T20:43:08Z")

</div>

Hello, I’m trying to get metadata “foobar” to feed into docker command, but the command is either escaped or any environment variables I set are ignored. Example (which is obviously truncated) below:

```auto
steps:
  - label: ":emoji: Run command in docker image"
    key: action-service
    plugins:
      - docker#v5.4.0:
          image: "registry.company.com/company-internal/tool-we-built:v1.0.11"
          command: ["command", "subcommand", "--flag", '$(buildkite-agent meta-data get foobar)']

```

How is one supposed to do this?

---

<div class="post-metadata">

### Author: ![paula](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/paula/32/954_2.png) [@paula](https://forum.buildkite.community/u/paula)
#### Post date: [February 26, 2023, 10:55pm UTC](https://forum.buildkite.community/t/feeding-meta-data-to-a-docker-plugin-command/2575/2 "2023-02-26T22:55:09Z")

</div>

Hi @masper!

Welcome to the community! You’ll probably want to specifically name the environment variable you want to be propagated in the `environment` property of the plug-in: [GitHub - buildkite-plugins/docker-buildkite-plugin: 🐳📦 Run any build step in a Docker container](https://github.com/buildkite-plugins/docker-buildkite-plugin#environment-optional-array)

Best!

---

<div class="post-metadata">

### Author: ![masper](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@masper](https://forum.buildkite.community/u/masper)
#### Post date: [February 27, 2023, 3:20pm UTC](https://forum.buildkite.community/t/feeding-meta-data-to-a-docker-plugin-command/2575/3 "2023-02-27T15:20:48Z")

</div>

How? I’m trying to feed it metadata and those aren’t propagated to an environment variable?

---

<div class="post-metadata">

### Author: ![masper](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@masper](https://forum.buildkite.community/u/masper)
#### Post date: [February 27, 2023, 3:28pm UTC](https://forum.buildkite.community/t/feeding-meta-data-to-a-docker-plugin-command/2575/4 "2023-02-27T15:28:02Z")

</div>

For context: I’ve tried this

```auto
environment:
  - "FOOBAR=$(buildkite-agent meta-data get foobar)"

```

and it was ignored, hence “any environment variables I set are ignored”

---

<div class="post-metadata">

### Author: ![masper](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@masper](https://forum.buildkite.community/u/masper)
#### Post date: [February 27, 2023, 6:31pm UTC](https://forum.buildkite.community/t/feeding-meta-data-to-a-docker-plugin-command/2575/5 "2023-02-27T18:31:46Z")

</div>

For people who stumble on this, the method I found workable is this:

```auto
FOODBAR=$$(buildkite-agent meta-data get foobar) buildkite-agent pipeline upload ./.buildkite/another-pipeline.yml

```

in another-pipeline.yml

```auto
steps:
  - label: ":emoji: Run command in docker image"
    key: action-service
    plugins:
      - docker#v5.4.0:
          image: "registry.company.com/company-internal/tool-we-built:v1.0.11"
          environment:
            - "FOOBAR=$FOOBAR"
          command: ["command", "subcommand", "--flag", "$FOOBAR"]

```

It’s not ideal since you can’t just directly use the plugin, but it’s the “buildkite” way of doing it

---

<div class="post-metadata">

### Author: ![paula](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/paula/32/954_2.png) [@paula](https://forum.buildkite.community/u/paula)
#### Post date: [August 29, 2023, 5:39am UTC](https://forum.buildkite.community/t/feeding-meta-data-to-a-docker-plugin-command/2575/6 "2023-08-29T05:39:30Z")

</div>


