jenkinsci / jenkinsci/docker-plugin

Race condition caused by not using image hash

Open
#772 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
498
Forks
324
Avg merge
1d 2h
Merged PRs (30d)
2

Description

- docker-plugin: 1.1.6
- jenkins: 2.214

Having this as part of declarative pipeline:
```
image = docker.build("project", "-f Dockerfile .")
image.push("version")
```

Current behavior essentially translates to:
```bash
docker build -t project -f Dockerfile .
docker tag project project:version
docker push project:version
```
If we expand defaults a bit it becomes:
```bash
docker build -t project:latest -f Dockerfile .
docker tag project:latest project:version
docker push project:version
```

The expected behavior however would be this:
```bash
image_hash=$(docker build -t project:latest -f Dockerfile -q .)
docker tag $image_hash project:version
docker push project:version
```

Rationale:
Current behavior is confusing because it allows race condition and you may end up with `project:version` image that doesn't correspond to the source code you were building.

Yes, there are easy ways to work around this by specifying tag explicitly, but still I think `image` entity in the pipeline should represent image that was just produced by its unique immutable hash.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.