Using Compose with build statement a container is not detected as running and recreated with each run
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 66/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- docker, docker-compose, ruby
- Domain
- devops, infrastructure
Research direction
Start by inspecting lib/puppet/provider/docker_compose/ruby.rb around line 71, where the issue identifies the image-name separator. Reproduce the setup with Docker Compose v2, then verify that an already-running container is not recreated on a subsequent puppet agent run and that the provider remains compatible with the reported workaround.
Written by the indexing model from the issue text.
Description
Describe the Bug
Using docker_compose together with a docker-compose.yaml with a custom build image like for example:
- docker-compose.yml:
version: '3.5'
services:
example:
build:
context: .
dockerfile: Dockerfile
- Dockerfile:
FROM alpine:3.14
CMD /bin/sh
- docker_example.pp:
class docker_example {
file { [
"/srv/docker-configs",
"/srv/docker-configs/example"]:
ensure => directory,
group => 'root',
owner => 'root'
}
file { '/srv/docker-configs/example/Dockerfile':
mode => '644',
source => 'example/Dockerfile',
require => File["/srv/docker-configs/example"]
}
exec {"docker-compose build":
cwd => "/srv/docker-configs/example",
path => "/usr/local/bin", # for updated docker-compose
refreshonly => true,
subscribe => [
File["/srv/docker-configs/example/Dockerfile"],
],
notify => Docker_compose["example"]
}
docker_compose { "example":
compose_file => ["/srv/docker-configs/example/docker-compose.yml"],
ensure => present,
require => File["/srv/docker-configs/example/docker-compose.yml"],
}
}
And having docker-compose >= 2.8.0 installed, one can observe the following issue.
Puppet does not detect the docker-container as already running and tries to recreates it with every puppet run.
The following message can be observed in the logs of puppet with each run
puppet-agent: (/Stage[main]/Docker_example/Dockercompose[example]/Docker_compose[example]/ensure) created (corrective)
Expected Behavior
The container is not attempted to be created as a corrective measure with each puppet agent run when it is already running.
Steps to Reproduce
Steps to reproduce the behavior:
- using the above setup
- run puppet agent -t
Environment
- Puppet Server Version 5.5.22
- Module Version Version 3.10.2, also tried more recent versions.
- Platform Ubuntu 22.04
- Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1
- Docker Compose version v2.18.0
Additional Context
During further analysis I was able to track the issue down to following changes:
- The separator for images built by docker-compose has been changed from
_to-with this commit: Docker compose - The Migrate to Compose V2 guide also states that this has been changed due to
_not being a valid character for DNS-names. - From July 2023 Compose V1 stopped receiving updates. It’s also no longer available in new releases of Docker Desktop.
Workaround:
- With a change of the separator https://github.com/puppetlabs/puppetlabs-docker/blob/65e36c1d77bf5212ca34601d87e32cb75e58b699/lib/puppet/provider/docker_compose/ruby.rb#L71 to
-, the issue cannot be observed anymore.
- Dominant language
- Ruby
- Stars
- 94
- Forks
- 337
- Avg merge
- 11d 15h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from puppetlabs/puppetlabs-docker
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
puppetlabs/puppetlabs-docker#973 · 6 comments · 5 reactions ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 52/100
puppetlabs/puppetlabs-docker#1053 · 1 comment ·
-
bug
Difficulty 1/5 1-3 hours Newbie friendliness 25/100
puppetlabs/puppetlabs-docker#1052 · 1 reaction ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
puppetlabs/puppetlabs-docker#1044 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 50/100
puppetlabs/puppetlabs-docker#1043 ·
All issues in puppetlabs/puppetlabs-docker
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100