Docker - /var/run/docker.sock (Communicating from container to the daemon)

Card Puncher Data Processing

About

/var/run/docker.sock is the socket where the docker daemon listens on by default and it can be used to communicate with the daemon from within a container.

Management

Configuration

The H option permits to configure the socket:

-H unix:///var/run/docker.sock

Usage

This socket permits you to communicate with the API. Example: Container listing:

docker-machine ssh
curl -X GET --unix-socket /var/run/docker.sock  -H 'Content-Type: application/json' http://localhost/containers/json
[{
		"Id": "551dc791bc086e792189452ecb5a43720c8f908f217fccd4c00614b2c6be81a1",
		"Names": ["/mssql_server"],
		"Image": "microsoft/mssql-server-linux:2017-latest",
		"ImageID": "sha256:cb3198f4b4d3eaa2bc257c993e9a015e7a467189e94d3fa9611db04357276168",
		"Command": "/bin/sh -c /opt/mssql/bin/sqlservr",
		"Created": 1518628009,
		"Ports": [{
				"IP": "0.0.0.0",
				"PrivatePort": 1433,
				"PublicPort": 1433,
				"Type": "tcp"
			}
		],
		"Labels": {
			"com.microsoft.product": "Microsoft SQL Server",
			"com.microsoft.version": "14.0.3015.40",
			"vendor": "Microsoft"
		},
		"State": "running",
		"Status": "Up 10 days",
		"HostConfig": {
			"NetworkMode": "default"
		},
		"NetworkSettings": {
			"Networks": {
				"bridge": {
					"IPAMConfig": null,
					"Links": null,
					"Aliases": null,
					"NetworkID": "bc7511d499738eaf4c17271f3c25d5eea71e35702189ce0eea4f219054778756",
					"EndpointID": "59d326b638c3fd8365899032df4fc5af6e76ce8b46cf981179e86f5af3cd19b1",
					"Gateway": "172.17.0.1",
					"IPAddress": "172.17.0.2",
					"IPPrefixLen": 16,
					"IPv6Gateway": "",
					"GlobalIPv6Address": "",
					"GlobalIPv6PrefixLen": 0,
					"MacAddress": "02:42:ac:11:00:02",
					"DriverOpts": null
				}
			}
		},
		"Mounts": []
	}
]

Documentation / Reference





Discover More
Jenkins Unlock
Jenkins - Docker Installation

Jenkins installation on Docker Create an container and run it from the Community edition image /var/run/docker.sock on Windows mounting JENKINS_HOME to a local directory (in our example to...



Share this page:
Follow us:
Task Runner