'How can I create container in azurite running from test container in java?

I am trying to test azure file upload using azurite docker image from test container below is code I am using for the same

public class AzureContainer {

    public static AzureContainer INSTANCE = new AzureContainer();

    private static final String connectionString = "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://0.0.0.0:10000/devstoreaccount1";

    private AzureContainer(){
        GenericContainer<?> azureContainer = new GenericContainer<>
                ("mcr.microsoft.com/azure-storage/azurite")
                .withCreateContainerCmdModifier(cmd -> cmd.withHostConfig(
                new HostConfig().withPortBindings(new PortBinding(Ports.Binding.bindPort(10000),
                        new ExposedPort(10000)))
        ));
        azureContainer.start();
    }

    public String getConnectionString() {
        return connectionString;
    }
}

Is there a way I can create container while starting the container itself? If I got and create container manually it is working fine but problem is when I am running code from CI/CD pipeline I can't create container manually.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source