fixed errors when providing docker container name in the parameter

This commit is contained in:
2021-06-11 01:52:31 +04:00
parent af46493aa9
commit c9b35ac790
3 changed files with 14 additions and 6 deletions

View File

@@ -93,11 +93,14 @@ func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerV
}
RespDocker.ImagePath = config.DefaultDockerFile
if ContainerName != "" {
// We are checking if the container name is not nil and not equal to the default one used
// which is docker-ubuntu-sshd
if ContainerName != "" && ContainerName != "docker-ubuntu-sshd" {
Containers, err := ViewAllContainers()
if err != nil {
return nil,err
}
for _, dockerContainer := range Containers.DockerContainer {
if dockerContainer.ContainerName == ContainerName {
RespDocker.ImagePath = config.DockerContainers + ContainerName + "/"
@@ -311,7 +314,6 @@ func ViewAllContainers() (*DockerContainers, error){
for _, f := range folders {
if f.IsDir() {
fmt.Print(f.Name())
//Declare variable DockerContainer of type struct
var Container DockerContainer