palantir / docker-compose-rule

A JUnit rule to manage docker containers using docker-compose
Apache License 2.0
425 stars 90 forks source link

Setting project name not effective #85

Open NeilRickards opened 8 years ago

NeilRickards commented 8 years ago

The projectName is being set on the DockerComposeExecutable:

private static final DockerComposeExecutable dockerComposeExecutable = ImmutableDockerComposeExecutable.builder()
        .dockerComposeFiles(DockerComposeFiles.from(DOCKER_COMPOSE_FILE))
        .dockerConfiguration(DOCKER_MACHINE)
        .projectName(ProjectName.fromString("salt"))
        .build();

But when I run docker ps there's still a random name:

ubuntu@box238:~$ docker ps
CONTAINER ID        IMAGE                                          COMMAND                  CREATED             STATUS              PORTS                                                                      NAMES
ba009f05e464        c7459e66_salt                                  "dockerize -timeout 1"   7 seconds ago       Up 6 seconds        0.0.0.0:6000->6000/tcp, 0.0.0.0:32775->5843/tcp, 0.0.0.0:32774->5845/tcp   c7459e66_salt_1

This is making it impossible to run dockerCompose.exec. It wasn't a problem in docker-compose-rule 0.5.2.

See Salt PR 330 for more context

harishutd commented 8 years ago

+1 This is blocking us as we want to pick up some of the latest changes that would help us do HA testing such as bringing a node up and down etc

iamdanfox commented 8 years ago

As a temporary workaround, you can interact with this projectName field in a different way (which works on 0.17.1):

    private static DockerComposeRule docker = DockerComposeRule.builder()
                                                               .saveLogsTo(logsLocation(DemoPathTest.class))
                                                               .files(dockerComposeYamlFile(DemoPathTest.class))
                                                               .addClusterWait(WEB, SELENIUM)
                                                               .addAllClusterWaits(F10_STACK)
                                                               .addClusterWait(HADOOP, HDFS_PROXY)
                                                               .projectName(ProjectName.fromString("demopathtest"))
                                                               .build();
NeilRickards commented 8 years ago

I've bumped to 0.17.1 and constructed a DockerComposeRule but it didn't make any difference. Looking at the code it's constructing the DockerComposeExecutable exactly the same.

iamdanfox commented 8 years ago

I wonder if the version of the docker-compose CLI is the problem here... I'm on 1.7.1.

NeilRickards commented 8 years ago

We are also on 1.7.1

NeilRickards commented 8 years ago

@j-baker helped unblock us by correctly using docker-compose exec. This is no longer blocking us. I'll leave this open as think there is still an issue with the project name not being used