/
docker_registry.go
42 lines (32 loc) · 1.28 KB
/
docker_registry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package docker
import (
"fmt"
"strings"
. "github.com/onsi/gomega"
"github.com/werf/werf/integration/pkg/utils"
)
func LocalDockerRegistryRun() (string, string, string) {
containerName := fmt.Sprintf("werf_test_docker_registry-%s", utils.GetRandomString(10))
imageName := "flant/werf-test:registry"
if exist := IsImageExist(imageName); !exist {
err := Pull(imageName)
Ω(err).ShouldNot(HaveOccurred(), "docker pull "+imageName)
}
dockerCliRunArgs := []string{
"-d",
"-p", ":5000",
"-e", "REGISTRY_STORAGE_DELETE_ENABLED=true",
"--name", containerName,
imageName,
}
err := CliRun(dockerCliRunArgs...)
Ω(err).ShouldNot(HaveOccurred(), "docker run "+strings.Join(dockerCliRunArgs, " "))
inspect := ContainerInspect(containerName)
Ω(inspect.NetworkSettings).ShouldNot(BeNil())
Ω(inspect.NetworkSettings.IPAddress).ShouldNot(BeEmpty())
registryInternalAddress := fmt.Sprintf("%s:%d", inspect.NetworkSettings.IPAddress, 5000)
registryLocalAddress := fmt.Sprintf("localhost:%s", ContainerHostPort(containerName, "5000/tcp"))
registryWithScheme := fmt.Sprintf("http://%s", registryLocalAddress)
utils.WaitTillHostReadyToRespond(registryWithScheme, utils.DefaultWaitTillHostReadyToRespondMaxAttempts)
return registryLocalAddress, registryInternalAddress, containerName
}