有没有办法将static public IP容器分配给容器.所以容器有公共IP.客户端可以使用IP访问容器.
我docker inspect用来获取图像信息.我发现有Config和ContainerConfig输出,以及最大的价值是相同的,除了CMD.
在实践中,Config生效.因为我必须在运行命令中添加cmd.
$ docker run -it debian bash
我想知道这两个项目的区别是什么?
$ docker inspect debian
[
{
"Id": "7abab0fd74f97b6b398a1aca68735c5be153d49922952f67e8696a2225e1d8e1",
......
"ContainerConfig": {
"Hostname": "e5c68db50333",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"/bin/sh",
"-c",
"#(nop) CMD [\"/bin/bash\"]"
],
"Image": "d8bd0657b25f17eef81a3d52b53da5bda4de0cf5cca3dcafec277634ae4b38fb",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"Config": {
"Hostname": "e5c68db50333",
"Domainname": "",
"User": "", …Run Code Online (Sandbox Code Playgroud) 我设置registry v2并使用nginx反向代理.当我将图像推送到注册时,它会出错413 Request Entity Too Large.
我在nginx.conf中将client_max_body_size修改为20MB.推动仍然失败.
registry v2
docker push的体型是多少?我怎样才能限制体型?
我是laravel发展的新生.我使用mysql数据库,并希望在数据库中插入原始数据.我添加了列$table->binary().如何将数据插入列.
Schema::table('users', function($table)
{
$table->binary('raw');
});
Run Code Online (Sandbox Code Playgroud) systemd的默认启动超时是90s.我想把它改成300s.所以我改变DefaultTimeoutStartSec的/etc/systemd/system.conf
# vi /etc/systemd/system.conf
DefaultTimeoutStartSec=90s
Run Code Online (Sandbox Code Playgroud)
但是如何让systemd重新加载/etc/systemd/system.conf呢?如果仅更改文件,则超时不会更改.
# systemctl show service -p TimeoutStartUSec
TimeoutStartUSec=1min 30s
Run Code Online (Sandbox Code Playgroud) 我尝试用swarm和设置docker cluster consul.我有manager,host1和host2.
我在经理上运行consul和swarm manager容器.
$ docker run --rm -p 8500:8500 progrium/consul -server -bootstrap
$ docker run -d -p 2377:2375 swarm manage consul://<manager>:8500
Run Code Online (Sandbox Code Playgroud)
在host1和host2上,我用--cluster-store和修改守护进程选项--cluster-advertise,然后重新启动docker daemon.
host1
DOCKER_OPTS="--cluster-store=consul://<manager>:8500 --cluster-advertise=<host1>:2375"
host2
DOCKER_OPTS="--cluster-store=consul://<manager>:8500 --cluster-advertise=<host2>:2375"
Run Code Online (Sandbox Code Playgroud)
当我将host1和host2加入swarm时,它会失败.
host1 $ docker run --rm swarm join --advertise=<host1>:2375 consul://<manager>:8500
host2 $ docker run --rm swarm join --advertise=<host2>:2375 consul://<manager>:8500
Run Code Online (Sandbox Code Playgroud)
从swarm管理器日志中,它出错了.
time="2016-01-20T02:17:17Z" level=error msg="Get http://<host1>:2375/v1.15/info: dial tcp <host1>:2375: getsockopt: connection refused" …Run Code Online (Sandbox Code Playgroud) 我使用静态文件模式向swarm集群添加了三个节点.我想从群集中删除host1.但是我没有找到-move来自swarm cmd.如何从群中删除节点?
Usage: swarm [OPTIONS] COMMAND [arg...]
Commands:
create, c Create a cluster
list, l List nodes in a cluster
manage, m Manage a docker cluster
join, j join a docker cluster
help, h Shows a list of commands or help for one command
Run Code Online (Sandbox Code Playgroud) 我使用 regexp.FindAll() 来获取所有匹配项。我不太明白这个参数n,而且office参考中,也没有解释。我该如何设置参数。
// FindAll is the 'All' version of Find; it returns a slice of all successive
// matches of the expression, as defined by the 'All' description in the
// package comment.
// A return value of nil indicates no match.
func (re *Regexp) FindAll(b []byte, n int) [][]byte {}
Run Code Online (Sandbox Code Playgroud) 我有以下代码将切片加倍。
func doubleSlice(s []int) []int {
t := make([]int, len(s), (cap(s) + 1) * 2 )
for i := range s {
t[i] = s[i]
}
return t
}
Run Code Online (Sandbox Code Playgroud)
我想使函子加倍任何类型的切片。我首先需要知道元素类型。
func showInterfaceItem(s interface{}) interface{} {
if reflect.TypeOf(s).Kind() != reflect.Slice {
fmt.Println("The interface is not a slice.")
return
}
var t interface{}
newLen := reflect.ValueOf(s).Len()
newCap := (cap(reflect.ValueOf(s).Cap()) + 1) * 2
t = make([]reflect.TypeOf(s), newLen, newCap)
return t
}
Run Code Online (Sandbox Code Playgroud)
所述reflect.TypeOf(s)返回接口{类型},元件的不类型。如何获取slice接口的元素类型?
我想递归地反映结构类型和值,但是失败了。我不知道如何递归地传递子结构。
错误如下。
panic: reflect: NumField of non-struct type
goroutine 1 [running]:
reflect.(*rtype).NumField(0xc0b20, 0xc82000a360)
/usr/local/go/src/reflect/type.go:660 +0x7b
Run Code Online (Sandbox Code Playgroud)
我有两个结构Person和Name
type Person struct {
Fullname NameType
Sex string
}
type Name struct {
Firstname string
Lastname string
}
Run Code Online (Sandbox Code Playgroud)
我Person在main中定义该结构,并使用递归函数显示该结构。
person := Person{
Name{"James", "Bound"},
"Male",
}
display(&person)
Run Code Online (Sandbox Code Playgroud)
的display函数递归显示结构。
func display(s interface{}) {
reflectType := reflect.TypeOf(s).Elem()
reflectValue := reflect.ValueOf(s).Elem()
for i := 0; i < reflectType.NumField(); i++ {
typeName := reflectType.Field(i).Name
valueType := reflectValue.Field(i).Type()
valueValue := reflectValue.Field(i).Interface()
switch …Run Code Online (Sandbox Code Playgroud) 我可以curl -sSL https://get.docker.com/ | sh在 Ubuntu 中安装 docker 。看了脚本,发现如果之前docker没有安装过apt-get install docker-engine,应该是有问题。
为了提高剧本,我想终止它,如果docker没有被安装apt-get。
我怎么知道dockerin是否安装了apt-get?
Warning: the "docker" command appears to already exist on this system.
If you already have Docker installed, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation.
If you installed the current Docker package using this script and are using it
again to …Run Code Online (Sandbox Code Playgroud) 我想有一个func来扫描文件夹并找到所有模板文件.然后调用template.ParseFiles来解析所有模板.我用它var tmplPathList []string来记录所有的模板,并传递tmplPathList给template.ParseFiles().
在func ParseFiles(filenames ...string) (*Template, error)使用... string的参数.编译错误cannot use tmplPathList (type []string) as type string in argument to "html/template".ParseFiles
我怎样才能转换[]string成... string?
var tmplPathList []string
for _, file := range tmplList {
tmplPathList = append(tmplPathList, dir + file.Name())
}
templates = template.Must(template.ParseFiles(tmplPathList))
Run Code Online (Sandbox Code Playgroud)