예제 #1
0
func TestNew(t *testing.T) {
	t.Parallel()
	daemon, err := dockertest.New()
	if err != nil {
		t.Fatal(err)
	}
	defer daemon.Close()

	hostIP := "10.1.1.100"
	runtime, err := docker.New(daemon.URL(), hostIP, "service", false)
	if err != nil {
		t.Error(err)
	} else if err := runtime.Close(); err != nil {
		t.Error(err)
	}
}
예제 #2
0
func DockerSetup() (*dockertest.Docker, error) {
	daemon, err := dockertest.New()
	if err != nil {
		return nil, errors.Wrap(err, "unable to start docker daemon")
	}

	client, err := daemon.Client()
	if err != nil {
		daemon.Close()
		return nil, errors.Wrapf(err, "unable to pull docker image %s:%s", DOCKER_IMAGE_REPO, DOCKER_IMAGE_TAG)
	}
	err = client.PullImage(dockerclient.PullImageOptions{
		Repository: DOCKER_IMAGE_REPO,
		Tag:        DOCKER_IMAGE_TAG,
	}, dockerclient.AuthConfiguration{})
	if err != nil {
		daemon.Close()
		return nil, errors.Wrapf(err, "unable to pull docker image %s:%s", DOCKER_IMAGE_REPO, DOCKER_IMAGE_TAG)
	}
	return daemon, nil
}