Export image/container metadata stored in graph driver. Right now 3 fields
DeviceId, DeviceSize and DeviceName are being exported from devicemapper.
Other graph drivers can export fields as they see fit.
This data can be used to mount the thin device outside of docker and tools
can look into image/container and do some kind of inspection.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
| ... | ... |
@@ -75,6 +75,11 @@ type Image struct {
|
| 75 | 75 |
Labels map[string]string |
| 76 | 76 |
} |
| 77 | 77 |
|
| 78 |
+type GraphDriverData struct {
|
|
| 79 |
+ Name string |
|
| 80 |
+ Data map[string]string |
|
| 81 |
+} |
|
| 82 |
+ |
|
| 78 | 83 |
// GET "/images/{name:.*}/json"
|
| 79 | 84 |
type ImageInspect struct {
|
| 80 | 85 |
Id string |
| ... | ... |
@@ -90,6 +95,7 @@ type ImageInspect struct {
|
| 90 | 90 |
Os string |
| 91 | 91 |
Size int64 |
| 92 | 92 |
VirtualSize int64 |
| 93 |
+ GraphDriver GraphDriverData |
|
| 93 | 94 |
} |
| 94 | 95 |
|
| 95 | 96 |
// GET "/containers/json" |
| ... | ... |
@@ -218,6 +224,7 @@ type ContainerJSONBase struct {
|
| 218 | 218 |
AppArmorProfile string |
| 219 | 219 |
ExecIDs []string |
| 220 | 220 |
HostConfig *runconfig.HostConfig |
| 221 |
+ GraphDriver GraphDriverData |
|
| 221 | 222 |
} |
| 222 | 223 |
|
| 223 | 224 |
type ContainerJSON struct {
|
| ... | ... |
@@ -162,6 +162,10 @@ func (a *Driver) Status() [][2]string {
|
| 162 | 162 |
} |
| 163 | 163 |
} |
| 164 | 164 |
|
| 165 |
+func (a *Driver) GetMetadata(id string) (map[string]string, error) {
|
|
| 166 |
+ return nil, nil |
|
| 167 |
+} |
|
| 168 |
+ |
|
| 165 | 169 |
// Exists returns true if the given id is registered with |
| 166 | 170 |
// this driver |
| 167 | 171 |
func (a *Driver) Exists(id string) bool {
|
| ... | ... |
@@ -127,6 +127,13 @@ type Status struct {
|
| 127 | 127 |
DeferredRemoveEnabled bool |
| 128 | 128 |
} |
| 129 | 129 |
|
| 130 |
+// Structure used to export image/container metadata in docker inspect. |
|
| 131 |
+type DeviceMetadata struct {
|
|
| 132 |
+ deviceId int |
|
| 133 |
+ deviceSize uint64 // size in bytes |
|
| 134 |
+ deviceName string // Device name as used during activation |
|
| 135 |
+} |
|
| 136 |
+ |
|
| 130 | 137 |
type DevStatus struct {
|
| 131 | 138 |
DeviceId int |
| 132 | 139 |
Size uint64 |
| ... | ... |
@@ -1700,6 +1707,20 @@ func (devices *DeviceSet) Status() *Status {
|
| 1700 | 1700 |
return status |
| 1701 | 1701 |
} |
| 1702 | 1702 |
|
| 1703 |
+// Status returns the current status of this deviceset |
|
| 1704 |
+func (devices *DeviceSet) ExportDeviceMetadata(hash string) (*DeviceMetadata, error) {
|
|
| 1705 |
+ info, err := devices.lookupDevice(hash) |
|
| 1706 |
+ if err != nil {
|
|
| 1707 |
+ return nil, err |
|
| 1708 |
+ } |
|
| 1709 |
+ |
|
| 1710 |
+ info.lock.Lock() |
|
| 1711 |
+ defer info.lock.Unlock() |
|
| 1712 |
+ |
|
| 1713 |
+ metadata := &DeviceMetadata{info.DeviceId, info.Size, info.Name()}
|
|
| 1714 |
+ return metadata, nil |
|
| 1715 |
+} |
|
| 1716 |
+ |
|
| 1703 | 1717 |
func NewDeviceSet(root string, doInit bool, options []string) (*DeviceSet, error) {
|
| 1704 | 1718 |
devicemapper.SetDevDir("/dev")
|
| 1705 | 1719 |
|
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
"io/ioutil" |
| 8 | 8 |
"os" |
| 9 | 9 |
"path" |
| 10 |
+ "strconv" |
|
| 10 | 11 |
|
| 11 | 12 |
"github.com/Sirupsen/logrus" |
| 12 | 13 |
"github.com/docker/docker/daemon/graphdriver" |
| ... | ... |
@@ -91,6 +92,20 @@ func (d *Driver) Status() [][2]string {
|
| 91 | 91 |
return status |
| 92 | 92 |
} |
| 93 | 93 |
|
| 94 |
+func (d *Driver) GetMetadata(id string) (map[string]string, error) {
|
|
| 95 |
+ m, err := d.DeviceSet.ExportDeviceMetadata(id) |
|
| 96 |
+ |
|
| 97 |
+ if err != nil {
|
|
| 98 |
+ return nil, err |
|
| 99 |
+ } |
|
| 100 |
+ |
|
| 101 |
+ metadata := make(map[string]string) |
|
| 102 |
+ metadata["DeviceId"] = strconv.Itoa(m.deviceId) |
|
| 103 |
+ metadata["DeviceSize"] = strconv.FormatUint(m.deviceSize, 10) |
|
| 104 |
+ metadata["DeviceName"] = m.deviceName |
|
| 105 |
+ return metadata, nil |
|
| 106 |
+} |
|
| 107 |
+ |
|
| 94 | 108 |
func (d *Driver) Cleanup() error {
|
| 95 | 109 |
err := d.DeviceSet.Shutdown() |
| 96 | 110 |
|
| ... | ... |
@@ -56,6 +56,9 @@ type ProtoDriver interface {
|
| 56 | 56 |
// Status returns a set of key-value pairs which give low |
| 57 | 57 |
// level diagnostic status about this driver. |
| 58 | 58 |
Status() [][2]string |
| 59 |
+ // Returns a set of key-value pairs which give low level information |
|
| 60 |
+ // about the image/container driver is managing. |
|
| 61 |
+ GetMetadata(id string) (map[string]string, error) |
|
| 59 | 62 |
// Cleanup performs necessary tasks to release resources |
| 60 | 63 |
// held by the driver, e.g., unmounting all layered filesystems |
| 61 | 64 |
// known to this driver. |
| ... | ... |
@@ -186,6 +186,10 @@ func (d *Driver) Status() [][2]string {
|
| 186 | 186 |
} |
| 187 | 187 |
} |
| 188 | 188 |
|
| 189 |
+func (d *Driver) GetMetadata(id string) (map[string]string, error) {
|
|
| 190 |
+ return nil, nil |
|
| 191 |
+} |
|
| 192 |
+ |
|
| 189 | 193 |
func (d *Driver) cloneFilesystem(name, parentName string) error {
|
| 190 | 194 |
snapshotName := fmt.Sprintf("%d", time.Now().Nanosecond())
|
| 191 | 195 |
parentDataset := zfs.Dataset{Name: parentName}
|
| ... | ... |
@@ -109,6 +109,13 @@ func (daemon *Daemon) getInspectData(container *Container) (*types.ContainerJSON |
| 109 | 109 |
HostConfig: &hostConfig, |
| 110 | 110 |
} |
| 111 | 111 |
|
| 112 |
+ contJSONBase.GraphDriver.Name = container.Driver |
|
| 113 |
+ graphDriverData, err := daemon.driver.GetMetadata(container.ID) |
|
| 114 |
+ if err != nil {
|
|
| 115 |
+ return nil, err |
|
| 116 |
+ } |
|
| 117 |
+ contJSONBase.GraphDriver.Data = graphDriverData |
|
| 118 |
+ |
|
| 112 | 119 |
return contJSONBase, nil |
| 113 | 120 |
} |
| 114 | 121 |
|
| ... | ... |
@@ -45,6 +45,13 @@ func (s *TagStore) Lookup(name string) (*types.ImageInspect, error) {
|
| 45 | 45 |
VirtualSize: s.graph.GetParentsSize(image, 0) + image.Size, |
| 46 | 46 |
} |
| 47 | 47 |
|
| 48 |
+ imageInspect.GraphDriver.Name = s.graph.driver.String() |
|
| 49 |
+ |
|
| 50 |
+ graphDriverData, err := s.graph.driver.GetMetadata(image.ID) |
|
| 51 |
+ if err != nil {
|
|
| 52 |
+ return nil, err |
|
| 53 |
+ } |
|
| 54 |
+ imageInspect.GraphDriver.Data = graphDriverData |
|
| 48 | 55 |
return imageInspect, nil |
| 49 | 56 |
} |
| 50 | 57 |
|
| ... | ... |
@@ -28,7 +28,7 @@ func (s *DockerSuite) TestInspectApiContainerResponse(c *check.C) {
|
| 28 | 28 |
c.Fatalf("unable to unmarshal body for latest version: %v", err)
|
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 |
- keys := []string{"State", "Created", "Path", "Args", "Config", "Image", "NetworkSettings", "ResolvConfPath", "HostnamePath", "HostsPath", "LogPath", "Name", "Driver", "ExecDriver", "MountLabel", "ProcessLabel", "Volumes", "VolumesRW"}
|
|
| 31 |
+ keys := []string{"State", "Created", "Path", "Args", "Config", "Image", "NetworkSettings", "ResolvConfPath", "HostnamePath", "HostsPath", "LogPath", "Name", "Driver", "ExecDriver", "MountLabel", "ProcessLabel", "Volumes", "VolumesRW", "GraphDriver"}
|
|
| 32 | 32 |
|
| 33 | 33 |
keys = append(keys, "Id") |
| 34 | 34 |
|
| ... | ... |
@@ -89,3 +89,70 @@ func (s *DockerSuite) TestInspectContainerFilterInt(c *check.C) {
|
| 89 | 89 |
c.Fatalf("Expected exitcode: %d for container: %s", exitCode, id)
|
| 90 | 90 |
} |
| 91 | 91 |
} |
| 92 |
+ |
|
| 93 |
+func (s *DockerSuite) TestInspectImageGraphDriver(c *check.C) {
|
|
| 94 |
+ imageTest := "emptyfs" |
|
| 95 |
+ name, err := inspectField(imageTest, "GraphDriver.Name") |
|
| 96 |
+ c.Assert(err, check.IsNil) |
|
| 97 |
+ |
|
| 98 |
+ if name != "devicemapper" && name != "overlay" && name != "vfs" && name != "zfs" && name != "btrfs" && name != "aufs" {
|
|
| 99 |
+ c.Fatalf("%v is not a valid graph driver name", name)
|
|
| 100 |
+ } |
|
| 101 |
+ |
|
| 102 |
+ if name != "devicemapper" {
|
|
| 103 |
+ return |
|
| 104 |
+ } |
|
| 105 |
+ |
|
| 106 |
+ deviceId, err := inspectField(imageTest, "GraphDriver.Data.DeviceId") |
|
| 107 |
+ c.Assert(err, check.IsNil) |
|
| 108 |
+ |
|
| 109 |
+ _, err = strconv.Atoi(deviceId) |
|
| 110 |
+ if err != nil {
|
|
| 111 |
+ c.Fatalf("failed to inspect DeviceId of the image: %s, %v", deviceId, err)
|
|
| 112 |
+ } |
|
| 113 |
+ |
|
| 114 |
+ deviceSize, err := inspectField(imageTest, "GraphDriver.Data.DeviceSize") |
|
| 115 |
+ c.Assert(err, check.IsNil) |
|
| 116 |
+ |
|
| 117 |
+ _, err = strconv.ParseUint(deviceSize, 10, 64) |
|
| 118 |
+ if err != nil {
|
|
| 119 |
+ c.Fatalf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err)
|
|
| 120 |
+ } |
|
| 121 |
+} |
|
| 122 |
+ |
|
| 123 |
+func (s *DockerSuite) TestInspectContainerGraphDriver(c *check.C) {
|
|
| 124 |
+ runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true") |
|
| 125 |
+ out, _, _, err := runCommandWithStdoutStderr(runCmd) |
|
| 126 |
+ if err != nil {
|
|
| 127 |
+ c.Fatalf("failed to run container: %v, output: %q", err, out)
|
|
| 128 |
+ } |
|
| 129 |
+ |
|
| 130 |
+ out = strings.TrimSpace(out) |
|
| 131 |
+ |
|
| 132 |
+ name, err := inspectField(out, "GraphDriver.Name") |
|
| 133 |
+ c.Assert(err, check.IsNil) |
|
| 134 |
+ |
|
| 135 |
+ if name != "devicemapper" && name != "overlay" && name != "vfs" && name != "zfs" && name != "btrfs" && name != "aufs" {
|
|
| 136 |
+ c.Fatalf("%v is not a valid graph driver name", name)
|
|
| 137 |
+ } |
|
| 138 |
+ |
|
| 139 |
+ if name != "devicemapper" {
|
|
| 140 |
+ return |
|
| 141 |
+ } |
|
| 142 |
+ |
|
| 143 |
+ deviceId, err := inspectField(out, "GraphDriver.Data.DeviceId") |
|
| 144 |
+ c.Assert(err, check.IsNil) |
|
| 145 |
+ |
|
| 146 |
+ _, err = strconv.Atoi(deviceId) |
|
| 147 |
+ if err != nil {
|
|
| 148 |
+ c.Fatalf("failed to inspect DeviceId of the image: %s, %v", deviceId, err)
|
|
| 149 |
+ } |
|
| 150 |
+ |
|
| 151 |
+ deviceSize, err := inspectField(out, "GraphDriver.Data.DeviceSize") |
|
| 152 |
+ c.Assert(err, check.IsNil) |
|
| 153 |
+ |
|
| 154 |
+ _, err = strconv.ParseUint(deviceSize, 10, 64) |
|
| 155 |
+ if err != nil {
|
|
| 156 |
+ c.Fatalf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err)
|
|
| 157 |
+ } |
|
| 158 |
+} |
| ... | ... |
@@ -30,143 +30,144 @@ each result. |
| 30 | 30 |
|
| 31 | 31 |
To get information on a container use its ID or instance name: |
| 32 | 32 |
|
| 33 |
- $ docker inspect 1eb5fabf5a03 |
|
| 34 |
- [{
|
|
| 35 |
- "AppArmorProfile": "", |
|
| 36 |
- "Args": [], |
|
| 37 |
- "Config": {
|
|
| 38 |
- "AttachStderr": false, |
|
| 39 |
- "AttachStdin": false, |
|
| 40 |
- "AttachStdout": false, |
|
| 41 |
- "Cmd": [ |
|
| 42 |
- "/usr/sbin/nginx" |
|
| 43 |
- ], |
|
| 44 |
- "Domainname": "", |
|
| 45 |
- "Entrypoint": null, |
|
| 46 |
- "Env": [ |
|
| 47 |
- "HOME=/", |
|
| 48 |
- "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
|
| 49 |
- ], |
|
| 50 |
- "ExposedPorts": {
|
|
| 51 |
- "80/tcp": {}
|
|
| 52 |
- }, |
|
| 53 |
- "Hostname": "1eb5fabf5a03", |
|
| 54 |
- "Image": "summit/nginx", |
|
| 55 |
- "Labels": {
|
|
| 56 |
- "com.example.vendor": "Acme", |
|
| 57 |
- "com.example.license": "GPL", |
|
| 58 |
- "com.example.version": "1.0" |
|
| 59 |
- }, |
|
| 60 |
- "MacAddress": "", |
|
| 61 |
- "NetworkDisabled": false, |
|
| 62 |
- "OnBuild": null, |
|
| 63 |
- "OpenStdin": false, |
|
| 64 |
- "StdinOnce": false, |
|
| 65 |
- "Tty": true, |
|
| 66 |
- "User": "", |
|
| 67 |
- "Volumes": null, |
|
| 68 |
- "WorkingDir": "", |
|
| 33 |
+ $ docker inspect d2cc496561d6 |
|
| 34 |
+[{
|
|
| 35 |
+ "Id": "d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47", |
|
| 36 |
+ "Created": "2015-06-08T16:18:02.505155285Z", |
|
| 37 |
+ "Path": "bash", |
|
| 38 |
+ "Args": [], |
|
| 39 |
+ "State": {
|
|
| 40 |
+ "Running": false, |
|
| 41 |
+ "Paused": false, |
|
| 42 |
+ "Restarting": false, |
|
| 43 |
+ "OOMKilled": false, |
|
| 44 |
+ "Dead": false, |
|
| 45 |
+ "Pid": 0, |
|
| 46 |
+ "ExitCode": 0, |
|
| 47 |
+ "Error": "", |
|
| 48 |
+ "StartedAt": "2015-06-08T16:18:03.643865954Z", |
|
| 49 |
+ "FinishedAt": "2015-06-08T16:57:06.448552862Z" |
|
| 50 |
+ }, |
|
| 51 |
+ "Image": "ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4", |
|
| 52 |
+ "NetworkSettings": {
|
|
| 53 |
+ "Bridge": "", |
|
| 54 |
+ "EndpointID": "", |
|
| 55 |
+ "Gateway": "", |
|
| 56 |
+ "GlobalIPv6Address": "", |
|
| 57 |
+ "GlobalIPv6PrefixLen": 0, |
|
| 58 |
+ "HairpinMode": false, |
|
| 59 |
+ "IPAddress": "", |
|
| 60 |
+ "IPPrefixLen": 0, |
|
| 61 |
+ "IPv6Gateway": "", |
|
| 62 |
+ "LinkLocalIPv6Address": "", |
|
| 63 |
+ "LinkLocalIPv6PrefixLen": 0, |
|
| 64 |
+ "MacAddress": "", |
|
| 65 |
+ "NetworkID": "", |
|
| 66 |
+ "PortMapping": null, |
|
| 67 |
+ "Ports": null, |
|
| 68 |
+ "SandboxKey": "", |
|
| 69 |
+ "SecondaryIPAddresses": null, |
|
| 70 |
+ "SecondaryIPv6Addresses": null |
|
| 71 |
+ }, |
|
| 72 |
+ "ResolvConfPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/resolv.conf", |
|
| 73 |
+ "HostnamePath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/hostname", |
|
| 74 |
+ "HostsPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/hosts", |
|
| 75 |
+ "LogPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47-json.log", |
|
| 76 |
+ "Name": "/adoring_wozniak", |
|
| 77 |
+ "RestartCount": 0, |
|
| 78 |
+ "Driver": "devicemapper", |
|
| 79 |
+ "ExecDriver": "native-0.2", |
|
| 80 |
+ "MountLabel": "", |
|
| 81 |
+ "ProcessLabel": "", |
|
| 82 |
+ "Volumes": {},
|
|
| 83 |
+ "VolumesRW": {},
|
|
| 84 |
+ "AppArmorProfile": "", |
|
| 85 |
+ "ExecIDs": null, |
|
| 86 |
+ "HostConfig": {
|
|
| 87 |
+ "Binds": null, |
|
| 88 |
+ "ContainerIDFile": "", |
|
| 89 |
+ "LxcConf": [], |
|
| 90 |
+ "Memory": 0, |
|
| 91 |
+ "MemorySwap": 0, |
|
| 92 |
+ "CpuShares": 0, |
|
| 93 |
+ "CpuPeriod": 0, |
|
| 94 |
+ "CpusetCpus": "", |
|
| 95 |
+ "CpusetMems": "", |
|
| 96 |
+ "CpuQuota": 0, |
|
| 97 |
+ "BlkioWeight": 0, |
|
| 98 |
+ "OomKillDisable": false, |
|
| 99 |
+ "Privileged": false, |
|
| 100 |
+ "PortBindings": {},
|
|
| 101 |
+ "Links": null, |
|
| 102 |
+ "PublishAllPorts": false, |
|
| 103 |
+ "Dns": null, |
|
| 104 |
+ "DnsSearch": null, |
|
| 105 |
+ "ExtraHosts": null, |
|
| 106 |
+ "VolumesFrom": null, |
|
| 107 |
+ "Devices": [], |
|
| 108 |
+ "NetworkMode": "bridge", |
|
| 109 |
+ "IpcMode": "", |
|
| 110 |
+ "PidMode": "", |
|
| 111 |
+ "UTSMode": "", |
|
| 112 |
+ "CapAdd": null, |
|
| 113 |
+ "CapDrop": null, |
|
| 114 |
+ "RestartPolicy": {
|
|
| 115 |
+ "Name": "no", |
|
| 116 |
+ "MaximumRetryCount": 0 |
|
| 69 | 117 |
}, |
| 70 |
- "Created": "2014-04-04T21:33:52.02361335Z", |
|
| 71 |
- "Driver": "devicemapper", |
|
| 72 |
- "ExecDriver": "native-0.1", |
|
| 73 |
- "ExecIDs": null, |
|
| 74 |
- "HostConfig": {
|
|
| 75 |
- "Binds": null, |
|
| 76 |
- "CapAdd": null, |
|
| 77 |
- "CapDrop": null, |
|
| 78 |
- "CgroupParent": "", |
|
| 79 |
- "ContainerIDFile": "", |
|
| 80 |
- "CpuShares": 512, |
|
| 81 |
- "CpusetCpus": "0,1", |
|
| 82 |
- "CpusetMems": "", |
|
| 83 |
- "Devices": [], |
|
| 84 |
- "Dns": null, |
|
| 85 |
- "DnsSearch": null, |
|
| 86 |
- "ExtraHosts": null, |
|
| 87 |
- "IpcMode": "", |
|
| 88 |
- "Links": null, |
|
| 89 |
- "LogConfig": {
|
|
| 90 |
- "Config": null, |
|
| 91 |
- "Type": "json-file" |
|
| 92 |
- }, |
|
| 93 |
- "LxcConf": null, |
|
| 94 |
- "Memory": 16777216, |
|
| 95 |
- "MemorySwap": -1, |
|
| 96 |
- "NetworkMode": "", |
|
| 97 |
- "PidMode": "", |
|
| 98 |
- "PortBindings": {
|
|
| 99 |
- "80/tcp": [ |
|
| 100 |
- {
|
|
| 101 |
- "HostIp": "0.0.0.0", |
|
| 102 |
- "HostPort": "80" |
|
| 103 |
- } |
|
| 104 |
- ] |
|
| 105 |
- }, |
|
| 106 |
- "Privileged": false, |
|
| 107 |
- "PublishAllPorts": false, |
|
| 108 |
- "ReadonlyRootfs": false, |
|
| 109 |
- "RestartPolicy": {
|
|
| 110 |
- "MaximumRetryCount": 0, |
|
| 111 |
- "Name": "" |
|
| 112 |
- }, |
|
| 113 |
- "SecurityOpt": null, |
|
| 114 |
- "Ulimits": null, |
|
| 115 |
- "VolumesFrom": null |
|
| 116 |
- } |
|
| 117 |
- "HostnamePath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/hostname", |
|
| 118 |
- "HostsPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/hosts", |
|
| 119 |
- "ID": "1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b", |
|
| 120 |
- "Image": "df53773a4390e25936f9fd3739e0c0e60a62d024ea7b669282b27e65ae8458e6", |
|
| 121 |
- "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log", |
|
| 122 |
- "MountLabel": "", |
|
| 123 |
- "Name": "/ecstatic_ptolemy", |
|
| 124 |
- "NetworkSettings": {
|
|
| 125 |
- "Bridge": "docker0", |
|
| 126 |
- "Gateway": "172.17.42.1", |
|
| 127 |
- "GlobalIPv6Address": "", |
|
| 128 |
- "GlobalIPv6PrefixLen": 0, |
|
| 129 |
- "IPAddress": "172.17.0.2", |
|
| 130 |
- "IPPrefixLen": 16, |
|
| 131 |
- "IPv6Gateway": "", |
|
| 132 |
- "LinkLocalIPv6Address": "", |
|
| 133 |
- "LinkLocalIPv6PrefixLen": 0, |
|
| 134 |
- "MacAddress": "", |
|
| 135 |
- "PortMapping": null, |
|
| 136 |
- "Ports": {
|
|
| 137 |
- "80/tcp": [ |
|
| 138 |
- {
|
|
| 139 |
- "HostIp": "0.0.0.0", |
|
| 140 |
- "HostPort": "80" |
|
| 141 |
- } |
|
| 142 |
- ] |
|
| 143 |
- } |
|
| 144 |
- }, |
|
| 145 |
- "Path": "/usr/sbin/nginx", |
|
| 146 |
- "ProcessLabel": "", |
|
| 147 |
- "ResolvConfPath": "/etc/resolv.conf", |
|
| 148 |
- "RestartCount": 0, |
|
| 149 |
- "State": {
|
|
| 150 |
- "Dead": false, |
|
| 151 |
- "Error": "", |
|
| 152 |
- "ExitCode": 0, |
|
| 153 |
- "FinishedAt": "0001-01-01T00:00:00Z", |
|
| 154 |
- "OOMKilled": false, |
|
| 155 |
- "Paused": false, |
|
| 156 |
- "Pid": 858, |
|
| 157 |
- "Restarting": false, |
|
| 158 |
- "Running": true, |
|
| 159 |
- "StartedAt": "2014-04-04T21:33:54.16259207Z", |
|
| 118 |
+ "SecurityOpt": null, |
|
| 119 |
+ "ReadonlyRootfs": false, |
|
| 120 |
+ "Ulimits": null, |
|
| 121 |
+ "LogConfig": {
|
|
| 122 |
+ "Type": "json-file", |
|
| 123 |
+ "Config": {}
|
|
| 160 | 124 |
}, |
| 161 |
- "Volumes": {},
|
|
| 162 |
- "VolumesRW": {},
|
|
| 125 |
+ "CgroupParent": "" |
|
| 126 |
+ }, |
|
| 127 |
+ "GraphDriver": {
|
|
| 128 |
+ "Name": "devicemapper", |
|
| 129 |
+ "Data": {
|
|
| 130 |
+ "DeviceId": "5", |
|
| 131 |
+ "DeviceName": "docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47", |
|
| 132 |
+ "DeviceSize": "171798691840" |
|
| 133 |
+ } |
|
| 134 |
+ }, |
|
| 135 |
+ "Config": {
|
|
| 136 |
+ "Hostname": "d2cc496561d6", |
|
| 137 |
+ "Domainname": "", |
|
| 138 |
+ "User": "", |
|
| 139 |
+ "AttachStdin": true, |
|
| 140 |
+ "AttachStdout": true, |
|
| 141 |
+ "AttachStderr": true, |
|
| 142 |
+ "ExposedPorts": null, |
|
| 143 |
+ "Tty": true, |
|
| 144 |
+ "OpenStdin": true, |
|
| 145 |
+ "StdinOnce": true, |
|
| 146 |
+ "Env": null, |
|
| 147 |
+ "Cmd": [ |
|
| 148 |
+ "bash" |
|
| 149 |
+ ], |
|
| 150 |
+ "Image": "fedora", |
|
| 151 |
+ "Volumes": null, |
|
| 152 |
+ "VolumeDriver": "", |
|
| 153 |
+ "WorkingDir": "", |
|
| 154 |
+ "Entrypoint": null, |
|
| 155 |
+ "NetworkDisabled": false, |
|
| 156 |
+ "MacAddress": "", |
|
| 157 |
+ "OnBuild": null, |
|
| 158 |
+ "Labels": {},
|
|
| 159 |
+ "Memory": 0, |
|
| 160 |
+ "MemorySwap": 0, |
|
| 161 |
+ "CpuShares": 0, |
|
| 162 |
+ "Cpuset": "" |
|
| 163 | 163 |
} |
| 164 |
- |
|
| 164 |
+} |
|
| 165 |
+] |
|
| 165 | 166 |
## Getting the IP address of a container instance |
| 166 | 167 |
|
| 167 | 168 |
To get the IP address of a container use: |
| 168 | 169 |
|
| 169 |
- $ docker inspect --format='{{.NetworkSettings.IPAddress}}' 1eb5fabf5a03
|
|
| 170 |
+ $ docker inspect --format='{{.NetworkSettings.IPAddress}}' d2cc496561d6
|
|
| 170 | 171 |
172.17.0.2 |
| 171 | 172 |
|
| 172 | 173 |
## Listing all port bindings |
| ... | ... |
@@ -175,7 +176,7 @@ One can loop over arrays and maps in the results to produce simple text |
| 175 | 175 |
output: |
| 176 | 176 |
|
| 177 | 177 |
$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} \
|
| 178 |
- {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' 1eb5fabf5a03
|
|
| 178 |
+ {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' d2cc496561d6
|
|
| 179 | 179 |
80/tcp -> 80 |
| 180 | 180 |
|
| 181 | 181 |
You can get more information about how to write a go template from: |
| ... | ... |
@@ -186,79 +187,79 @@ http://golang.org/pkg/text/template/. |
| 186 | 186 |
Use an image's ID or name (e.g., repository/name[:tag]) to get information |
| 187 | 187 |
on it. |
| 188 | 188 |
|
| 189 |
- $ docker inspect fc1203419df2 |
|
| 190 |
- [{
|
|
| 191 |
- "Architecture": "amd64", |
|
| 192 |
- "Author": "", |
|
| 193 |
- "Comment": "", |
|
| 194 |
- "Config": {
|
|
| 195 |
- "AttachStderr": false, |
|
| 196 |
- "AttachStdin": false, |
|
| 197 |
- "AttachStdout": false, |
|
| 198 |
- "Cmd": [ |
|
| 199 |
- "make", |
|
| 200 |
- "direct-test" |
|
| 201 |
- ], |
|
| 202 |
- "Domainname": "", |
|
| 203 |
- "Entrypoint": [ |
|
| 204 |
- "/dind" |
|
| 205 |
- ], |
|
| 206 |
- "Env": [ |
|
| 207 |
- "PATH=/go/bin:/usr/src/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", |
|
| 208 |
- ], |
|
| 209 |
- "ExposedPorts": null, |
|
| 210 |
- "Hostname": "242978536a06", |
|
| 211 |
- "Image": "c2b774c744afc5bea603b5e6c5218539e506649326de3ea0135182f299d0519a", |
|
| 212 |
- "Labels": {},
|
|
| 213 |
- "MacAddress": "", |
|
| 214 |
- "NetworkDisabled": false, |
|
| 215 |
- "OnBuild": [], |
|
| 216 |
- "OpenStdin": false, |
|
| 217 |
- "StdinOnce": false, |
|
| 218 |
- "Tty": false, |
|
| 219 |
- "User": "", |
|
| 220 |
- "Volumes": null, |
|
| 221 |
- "WorkingDir": "/go/src/github.com/docker/libcontainer" |
|
| 222 |
- }, |
|
| 223 |
- "Container": "1c00417f3812a96d3ebc29e7fdee69f3d586d703ab89c8233fd4678d50707b39", |
|
| 224 |
- "ContainerConfig": {
|
|
| 225 |
- "AttachStderr": false, |
|
| 226 |
- "AttachStdin": false, |
|
| 227 |
- "AttachStdout": false, |
|
| 228 |
- "Cmd": [ |
|
| 229 |
- "/bin/sh", |
|
| 230 |
- "-c", |
|
| 231 |
- "#(nop) CMD [\"make\" \"direct-test\"]" |
|
| 232 |
- ], |
|
| 233 |
- "Domainname": "", |
|
| 234 |
- "Entrypoint": [ |
|
| 235 |
- "/dind" |
|
| 236 |
- ], |
|
| 237 |
- "Env": [ |
|
| 238 |
- "PATH=/go/bin:/usr/src/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", |
|
| 239 |
- ], |
|
| 240 |
- "ExposedPorts": null, |
|
| 241 |
- "Hostname": "242978536a06", |
|
| 242 |
- "Image": "c2b774c744afc5bea603b5e6c5218539e506649326de3ea0135182f299d0519a", |
|
| 243 |
- "Labels": {},
|
|
| 244 |
- "MacAddress": "", |
|
| 245 |
- "NetworkDisabled": false, |
|
| 246 |
- "OnBuild": [], |
|
| 247 |
- "OpenStdin": false, |
|
| 248 |
- "StdinOnce": false, |
|
| 249 |
- "Tty": false, |
|
| 250 |
- "User": "", |
|
| 251 |
- "Volumes": null, |
|
| 252 |
- "WorkingDir": "/go/src/github.com/docker/libcontainer" |
|
| 253 |
- }, |
|
| 254 |
- "Created": "2015-04-07T05:34:39.079489206Z", |
|
| 255 |
- "DockerVersion": "1.5.0-dev", |
|
| 256 |
- "Id": "fc1203419df26ca82cad1dd04c709cb1b8a8a947bd5bcbdfbef8241a76f031db", |
|
| 257 |
- "Os": "linux", |
|
| 258 |
- "Parent": "c2b774c744afc5bea603b5e6c5218539e506649326de3ea0135182f299d0519a", |
|
| 259 |
- "Size": 0, |
|
| 260 |
- "VirtualSize": 613136466 |
|
| 261 |
- }] |
|
| 189 |
+ $ docker inspect ded7cd95e059 |
|
| 190 |
+[{
|
|
| 191 |
+ "Id": "ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4", |
|
| 192 |
+ "Parent": "48ecf305d2cf7046c1f5f8fcbcd4994403173441d4a7f125b1bb0ceead9de731", |
|
| 193 |
+ "Comment": "", |
|
| 194 |
+ "Created": "2015-05-27T16:58:22.937503085Z", |
|
| 195 |
+ "Container": "76cf7f67d83a7a047454b33007d03e32a8f474ad332c3a03c94537edd22b312b", |
|
| 196 |
+ "ContainerConfig": {
|
|
| 197 |
+ "Hostname": "76cf7f67d83a", |
|
| 198 |
+ "Domainname": "", |
|
| 199 |
+ "User": "", |
|
| 200 |
+ "AttachStdin": false, |
|
| 201 |
+ "AttachStdout": false, |
|
| 202 |
+ "AttachStderr": false, |
|
| 203 |
+ "ExposedPorts": null, |
|
| 204 |
+ "Tty": false, |
|
| 205 |
+ "OpenStdin": false, |
|
| 206 |
+ "StdinOnce": false, |
|
| 207 |
+ "Env": null, |
|
| 208 |
+ "Cmd": [ |
|
| 209 |
+ "/bin/sh", |
|
| 210 |
+ "-c", |
|
| 211 |
+ "#(nop) ADD file:4be46382bcf2b095fcb9fe8334206b584eff60bb3fad8178cbd97697fcb2ea83 in /" |
|
| 212 |
+ ], |
|
| 213 |
+ "Image": "48ecf305d2cf7046c1f5f8fcbcd4994403173441d4a7f125b1bb0ceead9de731", |
|
| 214 |
+ "Volumes": null, |
|
| 215 |
+ "VolumeDriver": "", |
|
| 216 |
+ "WorkingDir": "", |
|
| 217 |
+ "Entrypoint": null, |
|
| 218 |
+ "NetworkDisabled": false, |
|
| 219 |
+ "MacAddress": "", |
|
| 220 |
+ "OnBuild": null, |
|
| 221 |
+ "Labels": {}
|
|
| 222 |
+ }, |
|
| 223 |
+ "DockerVersion": "1.6.0", |
|
| 224 |
+ "Author": "Lokesh Mandvekar \u003clsm5@fedoraproject.org\u003e", |
|
| 225 |
+ "Config": {
|
|
| 226 |
+ "Hostname": "76cf7f67d83a", |
|
| 227 |
+ "Domainname": "", |
|
| 228 |
+ "User": "", |
|
| 229 |
+ "AttachStdin": false, |
|
| 230 |
+ "AttachStdout": false, |
|
| 231 |
+ "AttachStderr": false, |
|
| 232 |
+ "ExposedPorts": null, |
|
| 233 |
+ "Tty": false, |
|
| 234 |
+ "OpenStdin": false, |
|
| 235 |
+ "StdinOnce": false, |
|
| 236 |
+ "Env": null, |
|
| 237 |
+ "Cmd": null, |
|
| 238 |
+ "Image": "48ecf305d2cf7046c1f5f8fcbcd4994403173441d4a7f125b1bb0ceead9de731", |
|
| 239 |
+ "Volumes": null, |
|
| 240 |
+ "VolumeDriver": "", |
|
| 241 |
+ "WorkingDir": "", |
|
| 242 |
+ "Entrypoint": null, |
|
| 243 |
+ "NetworkDisabled": false, |
|
| 244 |
+ "MacAddress": "", |
|
| 245 |
+ "OnBuild": null, |
|
| 246 |
+ "Labels": {}
|
|
| 247 |
+ }, |
|
| 248 |
+ "Architecture": "amd64", |
|
| 249 |
+ "Os": "linux", |
|
| 250 |
+ "Size": 186507296, |
|
| 251 |
+ "VirtualSize": 186507296, |
|
| 252 |
+ "GraphDriver": {
|
|
| 253 |
+ "Name": "devicemapper", |
|
| 254 |
+ "Data": {
|
|
| 255 |
+ "DeviceId": "3", |
|
| 256 |
+ "DeviceName": "docker-253:1-2763198-ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4", |
|
| 257 |
+ "DeviceSize": "171798691840" |
|
| 258 |
+ } |
|
| 259 |
+ } |
|
| 260 |
+} |
|
| 261 |
+] |
|
| 262 | 262 |
|
| 263 | 263 |
# HISTORY |
| 264 | 264 |
April 2014, originally compiled by William Henry (whenry at redhat dot com) |