private List<DockerCommand> GetDockerCommands() { var cmd1 = new DockerCommand { Command = "run", Description = "Runs a Docker container", Examples = new List<DockerCommandExample> { new DockerCommandExample { Example = "docker run imageName", Description = "Creates a running container from the image. Pulls it from Docker Hub if the image is not local" }, new DockerCommandExample { Example = "docker run -d -p 8080:3000 imageName", Description = "Runs a container in 'daemon' mode with an external port of 8080 and a container port of 3000." } } }; var cmd2 = new DockerCommand { Command = "ps", Description = "Lists containers", Examples = new List<DockerCommandExample> { new DockerCommandExample { Example = "docker ps", Description = "Lists all running containers" }, new DockerCommandExample { Example = "docker ps -a", Description = "Lists all containers (even if they are not running)" } } }; return new List<DockerCommand> { cmd1, cmd2 }; }
public async Task InsertDockerCommandAsync(DockerCommand command) { _context.DockerCommands.Add(command); try { await _context.SaveChangesAsync(); } catch (Exception exp) { _logger.LogError($"Error in {nameof(InsertDockerCommandAsync)}: " + exp.Message); } }