我一直在参考my_func <- function(file = NULL, na.rm = TRUE, ncores = 2){
# begin parallel processing
raster::beginCluster(ncores, type='SOCK')
# load data from file as raster brick
data <- raster::brick(file)
# calculate the standard deviation of the brick
sd <- raster::clusterR(x = data, fun = function(data){ raster::calc(x = data, fun = sd, na.rm = na.rm) })
# calculate mean - for layer i, mean is the mean of all layers but i
set <- 1:raster::nbands(data) # marker to pass to for loop
mn <- data # creates raster object to be filled with results
for(i in set){
subset <- set[-i]
wrk <- raster::stack(x = data, bands = subset) # make stack of all but i
mn_i <- raster::clusterR(x = wrk, fun = function(wrk){ raster::calc(x = wrk, fun = mean, na.rm = na.rm) }) # calculate mean of stack
mn[[i]] <- mn_i # set values of appropriate band with results
}
# calculate z score
##### ERROR HERE #####
z <- raster::clusterR(x = data, fun = function(data, mn){ raster::overlay(x = data, y = mn, fun = function(data, mn){ data - mn }, na.rm = na.rm }, export = mn)
# normalize z score
##### I assume the error would also occur here #####
z <- raster::clusterR(x = data, fun = function(z, sd){ raster::overlay(x = z, y = sd, fun = function(z, sd){ z / sd }, na.rm = na.rm) }, export = sd)
# end parallel processing
raster::endCluster()
# return result
return(result)
}
来了解如何启动docker容器。当我们直接通过命令启动docker容器时,我们可以指定诸如https://docs.docker.com/engine/api/v1.24/
之类的内容并放置重启策略。
如何通过REST API做到这一点?
答案 0 :(得分:2)
实际上,当我们使用docker run
创建并启动容器时,可以指定重启策略,因此您应该期望在创建容器的POST /containers/create
端点中找到此功能
正如您在文档中所看到的,容器描述JSON的RestartPolicy
对象字段中确实存在一个HostConfig
字段。