private void runWithCompose(String cmd) { final DockerCompose dockerCompose; if (localCompose) { dockerCompose = new LocalDockerCompose(composeFiles, project); } else { dockerCompose = new ContainerisedDockerCompose(composeFiles, project); } dockerCompose .withCommand(cmd) .withEnv(env) .invoke(); }
/** * Bind a fixed port on the docker host to a container port * @param hostPort a port on the docker host, which must be available * @param containerPort a port in the container * @param protocol an internet protocol (tcp or udp) * @return this container */ public SELF withFixedExposedPort(int hostPort, int containerPort, InternetProtocol protocol) { super.addFixedExposedPort(hostPort, containerPort, protocol); return self(); } }
@Override public JdbcDatabaseContainer newInstance(String tag) { if (tag != null) { return new MySQLContainer(MySQLContainer.IMAGE + ":" + tag); } else { return newInstance(); } }
@Test public void testExposedHostWithNetwork() throws Exception { try (Network network = Network.newNetwork()) { assertResponse(new GenericContainer().withNetwork(network).withCommand("top")); } }
/** * {@inheritDoc} */ @Override public ExecResult execInContainer(Charset outputCharset, String... command) throws UnsupportedOperationException, IOException, InterruptedException { return ExecInContainerPattern.execInContainer(getContainerInfo(), outputCharset, command); }
@Override protected void configure() { addExposedPort(POSTGRESQL_PORT); addEnv("POSTGRES_DB", databaseName); addEnv("POSTGRES_USER", username); addEnv("POSTGRES_PASSWORD", password); setCommand("postgres"); }
/** * {@inheritDoc} */ @Override public SELF withClasspathResourceMapping(final String resourcePath, final String containerPath, final BindMode mode) { return withClasspathResourceMapping(resourcePath, containerPath, mode, SelinuxContext.NONE); }
/** * @return the ports on which to check if the container is ready */ protected Set<Integer> getLivenessCheckPorts() { return container.getLivenessCheckPorts(); }
@Override public SELF withUsername(final String username) { this.username = username; return self(); }
public CassandraContainer(String dockerImageName) { super(dockerImageName); addExposedPort(CQL_PORT); setStartupAttempts(3); }
public void exposeHostPorts(int... ports) { for (int port : ports) { PortForwardingContainer.INSTANCE.exposeHostPort(port); } } }
@Override public SELF withPassword(final String password) { this.password = password; return self(); }
/** * Adds a file system binding. Consider using {@link #withFileSystemBind(String, String, BindMode)} * for building a container in a fluent style. * * @param hostPath the file system path on the host * @param containerPath the file system path inside the container * @param mode the bind mode */ default void addFileSystemBind(final String hostPath, final String containerPath, final BindMode mode) { addFileSystemBind(hostPath, containerPath, mode, SelinuxContext.NONE); }
public LocalDockerCompose(List<File> composeFiles, String identifier) { validateFileList(composeFiles); this.composeFiles = composeFiles; this.identifier = identifier; }
/** * {@inheritDoc} */ @Override public SELF withStartupCheckStrategy(StartupCheckStrategy strategy) { this.startupCheckStrategy = strategy; return self(); }
public SELF withRecordingMode(VncRecordingMode recordingMode, File vncRecordingDirectory) { this.recordingMode = recordingMode; this.vncRecordingDirectory = vncRecordingDirectory; return self(); }
/** * Initialize Cassandra with init CQL script * <p> * CQL script will be applied after container is started (see using WaitStrategy) * * @param initScriptPath relative classpath resource */ public SELF withInitScript(String initScriptPath) { this.initScriptPath = initScriptPath; return self(); }
@Override public JdbcDatabaseContainer newInstance(String tag) { return new MSSQLServerContainer(MSSQLServerContainer.IMAGE + ":" + tag); } }
@Override public SELF withPassword(final String password) { this.password = password; return self(); } }