# Docker

**URL:** <https://hub.mender.io/t/docker/324>\
**Category:** Update Modules\
**Tags:** docker\
**Created:** [March 12, 2019, 8:48am UTC](https://hub.mender.io/t/docker/324 "2019-03-12T08:48:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![lluiscampos](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/lluiscampos/32/112_2.png) [@lluiscampos](https://hub.mender.io/u/lluiscampos)\
**Post date:** [March 12, 2019, 8:48am UTC](https://hub.mender.io/t/docker/324/1 "2019-03-12T08:48:14Z")

</div>

### Description

The Docker Update Module handles the Docker images that shall be running in the device. A deployment with this module will stop all currently running Docker containers in the device, and start new containers with the provided list of Docker images in the Mender Artifact.

In case of an unforeseen error during the process, the module will use the rollback mechanism of the Mender client to restore the previously running Docker containers.

### Specification

| | |
| --- | --- |
| Module name | docker |
| Supports rollback | yes |
| Requires restart | no |
| Artifact generation script | yes |
| Full operating system updater | no |
| Source code | [Update Module](https://github.com/mendersoftware/mender-update-modules/tree/master/docker/module/docker), [Artifact Generator](https://github.com/mendersoftware/mender-update-modules/tree/master/docker/module-artifact-gen/docker-artifact-gen) |
| Maintainer | Community |

## Prepare the device

This section describes how to setup your target device, i.e. the device to be updated. This will also be referred to as the device environment.

All commands outlined in this section should be run in the device environment.

### Prerequisites

This update module has the following prerequisites for the device environment:

- [Install Docker Engine](https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/), version 17.03 or later.
- A recent version of the JSON parser `jq` needs to be installed in the device.
- Ensure the device has a Bash Unix shell

How to install these depends on which OS you are running.

### Install the Update Module

Download the latest version of this Update Module by running:

```bash
mkdir -p /usr/share/mender/modules/v3 && wget -P /usr/share/mender/modules/v3 https://raw.githubusercontent.com/mendersoftware/mender-update-modules/master/docker/module/docker

```

## Prepare the development environment on your workstation

This section describes how to set up your development environment on your workstation.

All commands outlined in this section should be run in the development environment.

### Prerequisites

This Update Module has the following prerequisites for the development environment:

- [Install mender-artifact](https://docs.mender.io/downloads), version 3.1.0 or later

### Artifact creation

For convenience, an Artifact generator tool `docker-artifact-gen` is provided along the module. This tool will generate Mender Artifacts in the same format that the Update Module expects them.

Download `docker-artifact-gen`, by running the following command:

```bash
wget https://raw.githubusercontent.com/mendersoftware/mender-update-modules/master/docker/module-artifact-gen/docker-artifact-gen

```

Make it executable:

```bash
chmod +x docker-artifact-gen

```

Now generate a Mender Artifact using the following command:

```bash
ARTIFACT_NAME="my-container-update-1.0"
DEVICE_TYPE="my-device-type"
OUTPUT_PATH=my-container-update-1.0.mender
DOCKER_IMAGES="docker-image-1 docker-image2"
./docker-artifact-gen -n ${ARTIFACT_NAME} -t ${DEVICE_TYPE} -o ${OUTPUT_PATH} ${DOCKER_IMAGES}

```

- `ARTIFACT_NAME` - The name of the Mender Artifact
- `DEVICE_TYPE` - The compatible device type of this Mender Artifact
- `OUTPUT_PATH` - The path where to place the output Mender Artifact. This should always have a `.mender` suffix
- `DOCKER_IMAGES` - The list of Docker images that we want the target to run. Each item can be any valid name for Docker to pull images from (tags or digests). For example debian, debian:jessie, debian:latest, debian:sha256@…, etc

Note that the actual image id that will be added in the Artifact is the digest (sha256 hash) of the image, regardless of the tag used to pull it in. This will ensure that the device will pull the exact same version of each image than the generation tool used when preparing the Artifact.

You can either deploy this Artifact in managed mode with the Mender server (upload it under Releases in the server UI) or by using the Mender client only in [Standalone deployments](https://docs.mender.io/artifact-creation/standalone-deployment).

#### Artifact technical details

The Mender Artifact used by this Update Module has no payload files. Instead it uses the `Metadata` field to list the Docker images, which will be downloaded by the device. This meta-data is composed by a single `containers` JSON key with the array of images digests to be installed in the update.

As an example, the following update will install two specific versions of Docker images debian and ubuntu:

```bash
Updates:
  - Type: docker
    Provides:
      rootfs-image.docker.version: my-container-update-1.0
    Depends: {}
    Clears Provides: [rootfs-image.docker.*]
    Metadata:
      {
        "containers": [
          "debian@sha256:e11072c1614c08bf88b543fcfe09d75a0426d90896408e926454e88078274fcb",
          "ubuntu@sha256:99c35190e22d294cdace2783ac55effc69d32896daaa265f0bbedbcde4fbe3e5"
        ],
        "run_args": ""
      }
    Files: []

```

---

<div class="post-metadata">

**Author:** ![Prakash](https://avatars.discourse-cdn.com/v4/letter/p/3be4f8/32.png) [@Prakash](https://hub.mender.io/u/Prakash)\
**Post date:** [April 3, 2019, 5:43am UTC](https://hub.mender.io/t/docker/324/2 "2019-04-03T05:43:25Z")

</div>

Is there a way to pass arguments to container? If yes, how?

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [September 24, 2019, 9:42am UTC](https://hub.mender.io/t/docker/324/3 "2019-09-24T09:42:04Z")

</div>

23 posts were split to a new topic: [Issues with Docker Update Module](https://hub.mender.io/t/issues-with-docker-update-module/1059)

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [September 24, 2019, 9:40am UTC](https://hub.mender.io/t/docker/324/26 "2019-09-24T09:40:29Z")

</div>

2 posts were split to a new topic: [How can we create single mender artifact for multiple dockers?](https://hub.mender.io/t/how-can-we-create-single-mender-artifact-for-multiple-dockers/1058)

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [September 24, 2019, 9:39am UTC](https://hub.mender.io/t/docker/324/28 "2019-09-24T09:39:46Z")

</div>

3 posts were split to a new topic: [Does the Docker Update Module work with private DockerHub repositories?](https://hub.mender.io/t/does-the-docker-update-module-work-with-private-dockerhub-repositories/1057)

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [September 24, 2019, 9:38am UTC](https://hub.mender.io/t/docker/324/31 "2019-09-24T09:38:44Z")

</div>

5 posts were split to a new topic: [Issue with Mender Artifact signature when using Docker Update Module](https://hub.mender.io/t/issue-with-mender-artifact-signature-when-using-docker-update-module/1056)

---

<div class="post-metadata">

**Author:** ![lluiscampos](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/lluiscampos/32/112_2.png) [@lluiscampos](https://hub.mender.io/u/lluiscampos)\
**Post date:** [April 3, 2019, 7:14am UTC](https://hub.mender.io/t/docker/324/32 "2019-04-03T07:14:20Z")

</div>

Hi @Prakash and welcome to Mender Hub!

As it is, this Update Module does not support passing arguments to the container. However, it is pretty easy to create a new module based on this one that could achieve that.

Have a look at the Docker Update Module and generator source code (links in table above) for inspiration. One possibility could be to pass the parameters as an extra field in the meta-data contained in the Mender Artifact.

---

<div class="post-metadata">

**Author:** ![freibrun](https://avatars.discourse-cdn.com/v4/letter/f/5e9695/32.png) [@freibrun](https://hub.mender.io/u/freibrun)\
**Post date:** [December 13, 2019, 1:21pm UTC](https://hub.mender.io/t/docker/324/33 "2019-12-13T13:21:22Z")

</div>

I’m facing an issue when building a docker mender artifact. Somehow my docker tag is not used correctly. This is what I do:

> ARTIFACT\_NAME=“rabbit-mq:3.7.8-management”  
> DEVICE\_TYPE=“raspberrypi3”  
> OUTPUT\_PATH=“rabbit-mq:3.7.8-management.mender”  
> DOCKER\_IMAGES=“arm32v7/rabbitmq: **3.7.8-management** ”

> ./docker-artifact-gen -n ${ARTIFACT\_NAME} -t ${DEVICE\_TYPE} -o ${OUTPUT\_PATH} ${DOCKER\_IMAGES}

Then I deploy the created mender file to my target. There the following docker image gets downloaded:

> ![console](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/1X/19719ae7720b608848fa1360defc569811929c71.gif)

Any idea what happened with the docker tag?

I’m using mender-artifact 3.1.1

Update: I just figured out this is intentional behaviour of pulling a digested docker image and not linked to Mender. See here: [https://success.docker.com/article/images-tagging-vs-digests](https://success.docker.com/article/images-tagging-vs-digests)

---

<div class="post-metadata">

**Author:** ![lluiscampos](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/lluiscampos/32/112_2.png) [@lluiscampos](https://hub.mender.io/u/lluiscampos)\
**Post date:** [December 13, 2019, 5:10pm UTC](https://hub.mender.io/t/docker/324/34 "2019-12-13T17:10:00Z")

</div>

Hi @freibrun,

Good that you figured out. I didn’t know neither about this detail, so thank you for the knowledge sharing 🙂

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [April 14, 2020, 8:34am UTC](https://hub.mender.io/t/docker/324/35 "2020-04-14T08:34:48Z")

</div>

4 posts were split to a new topic: [Installer: failed to read and install update: reader: unsupported version: 3](https://hub.mender.io/t/installer-failed-to-read-and-install-update-reader-unsupported-version-3/1785)

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [August 24, 2020, 4:19pm UTC](https://hub.mender.io/t/docker/324/36 "2020-08-24T16:19:16Z")

</div>

9 posts were split to a new topic: [Permission denied error with Docker Update Module](https://hub.mender.io/t/permission-denied-error-with-docker-update-module/2353)

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [August 24, 2020, 4:19pm UTC](https://hub.mender.io/t/docker/324/45 "2020-08-24T16:19:58Z")

</div>

2 posts were merged into an existing topic: [Permission denied error with Docker Update Module](https://hub.mender.io/t/permission-denied-error-with-docker-update-module/2353/10)

---

<div class="post-metadata">

**Author:** ![nishad1092](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@nishad1092](https://hub.mender.io/u/nishad1092)\
**Post date:** [August 24, 2020, 4:20pm UTC](https://hub.mender.io/t/docker/324/46 "2020-08-24T16:20:38Z")

</div>

I have done these procedures during the installation itself. Something, somewhere the this particular file perm has changed…

---

<div class="post-metadata">

**Author:** ![nishad1092](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@nishad1092](https://hub.mender.io/u/nishad1092)\
**Post date:** [August 26, 2020, 3:34pm UTC](https://hub.mender.io/t/docker/324/47 "2020-08-26T15:34:12Z")

</div>

Hi @freibrun,

Im also getting the tag like this after deployment, How did you resolve it , it will help me alot…

---

<div class="post-metadata">

**Author:** ![nishad1092](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@nishad1092](https://hub.mender.io/u/nishad1092)\
**Post date:** [September 10, 2020, 9:55am UTC](https://hub.mender.io/t/docker/324/48 "2020-09-10T09:55:07Z")

</div>

Hi @lluiscampos,

For this docker update, I have dpeloyed it and then It stops the previous container and then runs the new docker pull, as mentioned.,  
But then after the device has restarted, the older docker also restarts, which is not likely isn’t it. How or why this is happening or how to prevent the previous to run, or can we remove the previous docker id, but if we remove the previous docker id, the rollback mechanism won’t work as in the update module.

---

<div class="post-metadata">

**Author:** ![lluiscampos](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/lluiscampos/32/112_2.png) [@lluiscampos](https://hub.mender.io/u/lluiscampos)\
**Post date:** [September 16, 2020, 1:28pm UTC](https://hub.mender.io/t/docker/324/49 "2020-09-16T13:28:08Z")

</div>

Hi @nishad1092,

I am sorry I don’t understand your message.

See the [source code](https://github.com/mendersoftware/mender/blob/master/support/modules/docker), the docker module is very simple as it is meant to demo the Mender Update Module capabilities. You probably need to extend it to cover more advance use cases.

---

<div class="post-metadata">

**Author:** ![nishad1092](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@nishad1092](https://hub.mender.io/u/nishad1092)\
**Post date:** [September 17, 2020, 3:01pm UTC](https://hub.mender.io/t/docker/324/50 "2020-09-17T15:01:53Z")

</div>

sure @lluiscampos

Ill take a look at it.

Thanks for the link.

---

<div class="post-metadata">

**Author:** ![azarubkin](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@azarubkin](https://hub.mender.io/u/azarubkin)\
**Post date:** [October 11, 2021, 9:31am UTC](https://hub.mender.io/t/docker/324/51 "2021-10-11T09:31:42Z")

</div>

Hello everyone,

Is it possible to update Docker container from local file with this Update Module? E.g. `docker save` to create tar archive of the image, and then `docker load` on the device to load the image from a local file?

This is needed for evaluating the feasibility of using Docker with devices which could be offline and updated through .mender files on USB stick.

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [October 13, 2021, 8:31am UTC](https://hub.mender.io/t/docker/324/52 "2021-10-13T08:31:06Z")

</div>

It doesn’t support this. But it’s just a script, it shouldn’t be hard to adapt it to use tars instead, and submit a new module “docker-tar” or something like that.

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [May 19, 2023, 12:49pm UTC](https://hub.mender.io/t/docker/324/53 "2023-05-19T12:49:44Z")

</div>

A post was split to a new topic: [Docker Update Module, jq on armv7](https://hub.mender.io/t/docker-update-module-jq-on-armv7/5852)
