我目前正在尝试使用ansible将docker注册表部署到Amazon ec2。我的食谱中的任务看起来像这样:
- name: run docker registry container
docker:
image: registry
name: docker-registry
state: reloaded
env:
SETTINGS_FLAVOR: local
STORAGE_PATH: /opt/docker-registry
SEARCH_BACKEND: sqlalchemy
volumes:
- "/data/docker-registry-server/opt/docker-registry:/opt/docker-registry"
ports:
- "5000:5000"
如您所见,注册表部署为docker中的容器。 这在某种程度上起作用。容器正确启动,但卷未正确安装。我通过运行检查了这个:
docker exec -t -i docker-registry touch /opt/docker-registry/touch.me
这会在应安装卷的文件夹中的容器中创建一个新文件。因此,此文件应显示在/data/docker-registry-server/opt/docker-registry
中的主机上,但不会显示。
运行docker inspect docker-registry
时,我得到了这个结果:
[{
"AppArmorProfile": "",
"Args": [],
"Config": {
"AttachStderr": false,
"AttachStdin": false,
"AttachStdout": false,
"Cmd": [
"docker-registry"
],
"CpuShares": 0,
"Cpuset": "",
"Domainname": "",
"Entrypoint": null,
"Env": [
"SETTINGS_FLAVOR=local",
"SEARCH_BACKEND=sqlalchemy",
"STORAGE_PATH=/opt/docker-registry",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"DOCKER_REGISTRY_CONFIG=/docker-registry/config/config_sample.yml"
],
"ExposedPorts": {
"5000/tcp": {}
},
"Hostname": "7d4bb2448234",
"Image": "registry",
"MacAddress": "",
"Memory": 0,
"MemorySwap": 0,
"NetworkDisabled": false,
"OnBuild": null,
"OpenStdin": false,
"PortSpecs": null,
"StdinOnce": false,
"Tty": false,
"User": "",
"Volumes": {
"/opt/docker-registry": {}
},
"WorkingDir": ""
},
"Created": "2015-04-20T14:00:44.547620575Z",
"Driver": "devicemapper",
"ExecDriver": "native-0.2",
"ExecIDs": [
"5ea0f2a69b5010ee769963ea030dbf5016bef15f50515c120c3e1d27edb64e03",
"4d7cdbc371bc7bd7eddc73f531fe4e538186556b59b20da74ffa705ab31306c0"
],
"HostConfig": {
"Binds": [
"/data/docker-registry-server/opt/docker-registry:/opt/docker-registry:rw"
],
"CapAdd": null,
"CapDrop": null,
"ContainerIDFile": "",
"Devices": null,
"Dns": null,
"DnsSearch": null,
"ExtraHosts": null,
"IpcMode": "",
"Links": null,
"LxcConf": null,
"NetworkMode": "",
"PidMode": "",
"PortBindings": {
"5000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "5000"
}
]
},
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"RestartPolicy": {
"MaximumRetryCount": 0,
"Name": ""
},
"SecurityOpt": null,
"VolumesFrom": null
},
"HostnamePath": "/var/lib/docker/containers/7d4bb2448234962ba8f9da87d3650b38e608a1e405130ba6b35200f52e07ce5b/hostname",
"HostsPath": "/var/lib/docker/containers/7d4bb2448234962ba8f9da87d3650b38e608a1e405130ba6b35200f52e07ce5b/hosts",
"Id": "7d4bb2448234962ba8f9da87d3650b38e608a1e405130ba6b35200f52e07ce5b",
"Image": "59b1f7d49dc843631b9be86f581f9c8a726f7cea8a5c37e648c822e40e440633",
"MountLabel": "",
"Name": "/docker-registry",
"NetworkSettings": {
"Bridge": "docker0",
"Gateway": "172.17.42.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.62",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"LinkLocalIPv6Address": "fe80::42:acff:fe11:3e",
"LinkLocalIPv6PrefixLen": 64,
"MacAddress": "02:42:ac:11:00:3e",
"PortMapping": null,
"Ports": {
"5000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "5000"
}
]
}
},
"Path": "docker-registry",
"ProcessLabel": "",
"ResolvConfPath": "/var/lib/docker/containers/7d4bb2448234962ba8f9da87d3650b38e608a1e405130ba6b35200f52e07ce5b/resolv.conf",
"RestartCount": 0,
"State": {
"Error": "",
"ExitCode": 0,
"FinishedAt": "0001-01-01T00:00:00Z",
"OOMKilled": false,
"Paused": false,
"Pid": 21595,
"Restarting": false,
"Running": true,
"StartedAt": "2015-04-20T14:00:44.791121849Z"
},
"Volumes": {
"/opt/docker-registry": "/data/docker-registry-server/opt/docker-registry"
},
"VolumesRW": {
"/opt/docker-registry": true
}
}
]
这让我觉得容器本身就知道它应该使用一个卷。 Volumes
条目列出了正确的路径。所以这很可能是一个码头工人,而不是一个可靠的问题。
我正在使用docker 1.5.0,构建a8a31ed / 1.5.0
此时我确信在如何使用卷方面很可能存在一个愚蠢的错误。 (很可能是我的错...)
有谁能告诉我哪里出错了?
答案 0 :(得分:0)
既然你说通过移动你正在安装的文件夹它可以工作,我会检查一些事情:
确保您正在装载的目录实际存在于主机上。
确保您运行ansible playbook的用户具有访问您尝试安装的文件夹的正确权限。