def __init__(self,
                 stdout: bool,
                 log_location: str,
                 image_name: str,
                 host_name: str,
                 container_name: str = "corecpro_shell"):
        super().__init__(stdout, log_location, container_name)
        if log_location:
            self.log: Logger = Logger(location_shell=log_location)
        else:
            self.log: Logger = Logger()
        self.log.stdout = stdout
        self.image_name: str = image_name
        self.host_name: str = host_name
        self.container_name: str = container_name + "_" + str(time.time())

        docker_init = subprocess.run([
            'docker', 'run', '-dit', '-h', self.host_name, '--name',
            self.container_name, self.image_name, self.shell
        ],
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE)
        if docker_init.stderr:
            Out.err("Docker container failed to initialize.")
            Out.err("SYSTEM: " + docker_init.stderr.decode("UTF-8"))
            raise ChildProcessError()
        else:
            self.container_id: str = docker_init.stdout[0:len(docker_init.
                                                              stdout) -
                                                        1].decode("UTF-8")
            Out.norm("Docker container ID  : " + self.container_id)
            Out.norm("Docker container name: " + self.container_name)
            Out.good("Docker container successfully initialized.")
    def __init__(self,
                 stdout: bool,
                 log_location: str,
                 container_name: str = "corecpro_shell"):
        super().__init__(stdout, log_location, container_name)

        rand: bytes = ''.join(
            choice(digits + ascii_letters) for n in range(20)).encode()
        docker_run = self._raw_cmd(b'echo ' + rand)
        if docker_run[0] != b'':
            Out.err("Failed to connect to Docker container " +
                    self.container_name + ".")
            Out.err("SYSTEM: " + docker_run[0].decode('UTF-8'))
            raise ChildProcessError()
        elif docker_run[1][:-1] != rand:
            Out.err("Failed to verify connectivity, but no error is thrown.")
            Out.err("We sent the following command: echo " +
                    rand.decode('UTF-8'))
            Out.err("We expected to receive: " + rand.decode('UTF-8'))
            Out.err("Instead we got: " + docker_run[1].decode('UTF-8'))
            Out.err("Please report this error.")
            raise ChildProcessError()
        else:
            Out.good("Successfully connected to Docker container " +
                     self.container_name)