Skip to content

Commit

Permalink
fix: swarm remove container
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Sep 10, 2022
1 parent 32f5a7f commit 65f9856
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions GZCTF/Services/DockerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task DestoryContainer(Container container, CancellationToken token
try
{
if (options.SwarmMode)
await dockerClient.Swarm.RemoveServiceAsync(container.Id, token);
await dockerClient.Swarm.RemoveServiceAsync(container.ContainerId, token);
else
await dockerClient.Containers.RemoveContainerAsync(container.ContainerId, new() { Force = true }, token);
}
Expand Down Expand Up @@ -137,18 +137,13 @@ private ServiceCreateParameters GetServiceCreateParameters(ContainerConfig confi
}

// FIXME: will service start automatically?

logger.SystemLog($"ServiceCreateParameters: {JsonSerializer.Serialize(parameters)}", TaskStatus.Pending, LogLevel.Debug);
logger.SystemLog($"ServiceCreateResponse: {JsonSerializer.Serialize(serviceRes)}", TaskStatus.Pending, LogLevel.Debug);

Container container = new()
{
ContainerId = serviceRes.ID,
Image = config.Image,
};

var res = await dockerClient.Swarm.InspectServiceAsync(serviceRes.ID, token);
logger.SystemLog($"InspectService: {JsonSerializer.Serialize(res)}", TaskStatus.Pending, LogLevel.Debug);

var port = res.Endpoint.Ports.FirstOrDefault();

Expand Down

0 comments on commit 65f9856

Please sign in to comment.