diff --git a/changelog.adoc b/changelog.adoc index 5142cd2a6..8abce0da0 100644 --- a/changelog.adoc +++ b/changelog.adoc @@ -12,6 +12,7 @@ and this project tries to adhere to https://semver.org/spec/v2.0.0.html[Semantic * https://github.com/docToolchain/docToolchain/issues/395[#395 asciidoctor-diagram: ERROR: Failed to generate image: PlantUML image generation failed] * https://github.com/docToolchain/docToolchain/issues/455[#455 Force execution to stop with failure on missing image reference] * https://github.com/docToolchain/docToolchain/issues/621[#621: dtcw - sdkman installation check returns wrong result] +* https://github.com/docToolchain/docToolchain/issues/829[#829: Multiple run of dtcw with docker is failing because of a container name conflict] * https://github.com/docToolchain/docToolchain/issues/831[#831: fix for generateSite: images-hrefs not correct] * https://github.com/docToolchain/docToolchain/issues/973[#973: `dtcw getJava` doesn't work without `local`] * https://github.com/docToolchain/docToolchain/issues/1109[#1109: docToolchain release notes contain releases twice] diff --git a/dtcw b/dtcw index 207de2077..48c31f476 100755 --- a/dtcw +++ b/dtcw @@ -588,8 +588,10 @@ build_command() { # TODO: DTC_PROJECT_BRANCH is not passed into the docker environment # See https://github.com/docToolchain/docToolchain/issues/1087 + local container_name=doctoolchain-${version} + container_name+="-$(date '+%Y%m%d_%H%M%S')" pwd=$(has cygpath && cygpath -w "${PWD}" || echo "${PWD}") - docker_args="run --rm -i --platform linux/amd64 -u $(id -u):$(id -g) --name doctoolchain${version} \ + docker_args="run --rm -i --platform linux/amd64 -u $(id -u):$(id -g) --name ${container_name} \ -e DTC_HEADLESS=true -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=${DTC_PROJECT_BRANCH} -p 8042:8042 \ --entrypoint /bin/bash -v '${pwd}:/project' doctoolchain/doctoolchain:v${version}" diff --git a/test/docker_environment.bats b/test/docker_environment.bats index dcd817d43..c68bd424d 100644 --- a/test/docker_environment.bats +++ b/test/docker_environment.bats @@ -20,6 +20,11 @@ teardown() { @test "forward call to docker" { # No local install, but docker is present mock_docker=$(mock_create docker) + # Replace 'date' provided by 'minimal_system' with a mock + rm "${minimal_system}/date" && mock_date=$(mock_create date) + # Use timestamp to avoid container name conflicts. Second should be enough to avoid collisions. + timestamp=20230501_145800 + mock_set_output "${mock_date}" ${timestamp} PATH="${minimal_system}" run -0 ./dtcw tasks --group doctoolchain @@ -28,7 +33,7 @@ teardown() { assert_line "Using environment: docker" expected_cmd="run --rm -i --platform linux/amd64 -u $(id -u):$(id -g) \ ---name doctoolchain${DTC_VERSION} -e DTC_HEADLESS=true -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=test \ +--name doctoolchain-${DTC_VERSION}-${timestamp} -e DTC_HEADLESS=true -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=test \ -p 8042:8042 --entrypoint /bin/bash -v ${PWD}:/project doctoolchain/doctoolchain:v${DTC_VERSION} \ -c doctoolchain . tasks --group doctoolchain -PmainConfigFile=docToolchainConfig.groovy --warning-mode=none --no-daemon && exit" assert_equal "$(mock_get_call_args "${mock_docker}")" "${expected_cmd}"