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 /// 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); ExposedPort tcpSsh = ExposedPort.tcp(2222);
Ports portBindings = new Ports(); Ports portBindings = new Ports();
@ -199,8 +199,8 @@ public class DockerService {
.withExposedPorts(tcpSsh) .withExposedPorts(tcpSsh)
.withHostConfig(hostConfig) .withHostConfig(hostConfig)
.withEnv("SUDO_ACCESS=false", "PASSWORD_ACCESS=true", .withEnv("SUDO_ACCESS=false", "PASSWORD_ACCESS=true",
"USER_NAME=test", // TODO : User login "USER_NAME="+username, // TODO : User login
"USER_PASSWORD=test" // TODO : Random passwd "USER_PASSWORD="+password // TODO : Random passwd
) )
.exec(); .exec();

View File

@ -62,8 +62,8 @@ public class InstanceService {
public void createContainer(Long instanceId) { public void createContainer(Long instanceId) {
Instance instance = instanceRepository.findById(instanceId); Instance instance = instanceRepository.findById(instanceId);
if (instance.containerId.equals("Not created")) if (instance.containerId.equals("Not created"))
instance.containerId = instance.containerId = dockerService.createContainer(
dockerService.createContainer(instance.name, instance.port); instance.name, instance.port, "test", "test");
} }
public InspectContainerResponse.ContainerState getStatusContainer(Long id) { public InspectContainerResponse.ContainerState getStatusContainer(Long id) {
@ -95,7 +95,6 @@ public class InstanceService {
return dockerService.remove(instance.name); return dockerService.remove(instance.name);
} }
@Transactional @Transactional
public void deleteInstance(Long id) { public void deleteInstance(Long id) {
Instance instance = instanceRepository.findById(id); Instance instance = instanceRepository.findById(id);