preparations to have random password for containers

This commit is contained in:
Arthur Wambst 2025-10-20 17:23:06 +02:00
parent 2eab309cb2
commit 3e2ebac614
No known key found for this signature in database
2 changed files with 8 additions and 9 deletions

View File

@ -171,7 +171,7 @@ public class DockerService {
///////////////////////////////////////////////////////////////////////////
///
/// First, we create our container and basic functions
public String createContainer(String name, int port) {
public String createContainer(String name, int port, String username, String password) {
ExposedPort tcpSsh = ExposedPort.tcp(2222);
Ports portBindings = new Ports();
@ -199,8 +199,8 @@ public class DockerService {
.withExposedPorts(tcpSsh)
.withHostConfig(hostConfig)
.withEnv("SUDO_ACCESS=false", "PASSWORD_ACCESS=true",
"USER_NAME=test", // TODO : User login
"USER_PASSWORD=test" // TODO : Random passwd
"USER_NAME="+username, // TODO : User login
"USER_PASSWORD="+password // TODO : Random passwd
)
.exec();

View File

@ -62,8 +62,8 @@ public class InstanceService {
public void createContainer(Long instanceId) {
Instance instance = instanceRepository.findById(instanceId);
if (instance.containerId.equals("Not created"))
instance.containerId =
dockerService.createContainer(instance.name, instance.port);
instance.containerId = dockerService.createContainer(
instance.name, instance.port, "test", "test");
}
public InspectContainerResponse.ContainerState getStatusContainer(Long id) {
@ -95,7 +95,6 @@ public class InstanceService {
return dockerService.remove(instance.name);
}
@Transactional
public void deleteInstance(Long id) {
Instance instance = instanceRepository.findById(id);
@ -105,7 +104,7 @@ public class InstanceService {
}
///////////////////////////////////////////////////////////////////////////
///UTILS FOR PORTS NUMBERS HANDLING
/// UTILS FOR PORTS NUMBERS HANDLING
public Set<Integer> getUsedPorts() {
Set<Integer> retour = new HashSet<>();
List<Instance> allInstances = getAllInstances();