From the docker desktop, on the printer’s container if I execute the command:
curl localhost:631/printers
I get the following:
curl: (7) Failed to connect to localhost port 631 after 0 ms: Connection refused
If I get the docker container address doing:
docker container inspect cups
I get:
{
"Id": "1941403add06bb82c450e022a8006980bec51433b1f80742c8ca1eb4be888bb6",
"Created": "2023-01-07T14:15:27.89768401Z",
"Path": "/usr/sbin/cupsd",
"Args": [
"-l"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 16601,
"ExitCode": 0,
"Error": "",
"StartedAt": "2023-01-07T14:15:28.207492343Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:c17c5c6a261293b28246b4391306fd5295211fd0376dbb439ee892017e5fa94b",
"ResolvConfPath": "/var/lib/docker/containers/1941403add06bb82c450e022a8006980bec51433b1f80742c8ca1eb4be888bb6/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/1941403add06bb82c450e022a8006980bec51433b1f80742c8ca1eb4be888bb6/hostname",
"HostsPath": "/var/lib/docker/containers/1941403add06bb82c450e022a8006980bec51433b1f80742c8ca1eb4be888bb6/hosts",
"LogPath": "/var/lib/docker/containers/1941403add06bb82c450e022a8006980bec51433b1f80742c8ca1eb4be888bb6/1941403add06bb82c450e022a8006980bec51433b1f80742c8ca1eb4be888bb6-json.log",
"Name": "/cups",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": [
"d23b8113c8d84b90b56a44d4b585d82b337e66b6206a338c99848691ff704ced"
],
"HostConfig": {
"Binds": [],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "java-device_agent_printing_default",
"PortBindings": {
"631/tcp": [
{
"HostIp": "",
"HostPort": "631"
}
]
},
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "private",
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": [],
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": true,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": [
"label=disable"
],
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [
{
"PathOnHost": "/dev/bus/usb",
"PathInContainer": "/dev/bus/usb",
"CgroupPermissions": "rwm"
}
],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": null,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": null,
"ReadonlyPaths": null
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/07917ef7ed081964b293a793e1a52acae0af0ca98393a826600acc7a6b7a789f-init/diff:/var/lib/docker/overlay2/b2jyfy1g05whxxt76zr1e3kyg/diff:/var/lib/docker/overlay2/vam1nxh7j9a67jfdgymq665bc/diff:/var/lib/docker/overlay2/z8lqmjqihtiqmn2y9xppmbqxg/diff:/var/lib/docker/overlay2/p86sfuod2e9rzxi5p9brv9lm6/diff:/var/lib/docker/overlay2/4vgiuae3q1pwce82tq0p7lq0o/diff:/var/lib/docker/overlay2/vfnic7ebdc0q65x5b44gq45a7/diff:/var/lib/docker/overlay2/b07190ae26534601fdc86fa6bb19c5e9f87c9eb8dc36ecd03fd2bc9ce7487f57/diff",
"MergedDir": "/var/lib/docker/overlay2/07917ef7ed081964b293a793e1a52acae0af0ca98393a826600acc7a6b7a789f/merged",
"UpperDir": "/var/lib/docker/overlay2/07917ef7ed081964b293a793e1a52acae0af0ca98393a826600acc7a6b7a789f/diff",
"WorkDir": "/var/lib/docker/overlay2/07917ef7ed081964b293a793e1a52acae0af0ca98393a826600acc7a6b7a789f/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "cups",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"631/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"CUPSADMIN=admin",
"CUPSPASSWORD=password",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"JAVA_HOME=/usr/lib/jvm/jre",
"JAVA_VENDOR=openjdk",
"JAVA_VERSION=17.0"
],
"Cmd": [
"/usr/sbin/cupsd",
"-l"
],
"Image": "cups",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "143105b5d8f107fbe1540586a7ac4888833207036f3cba4ea8eb078a78689df9",
"com.docker.compose.container-number": "1",
"com.docker.compose.depends_on": "",
"com.docker.compose.image": "sha256:c17c5c6a261293b28246b4391306fd5295211fd0376dbb439ee892017e5fa94b",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "java-device_agent_printing",
"com.docker.compose.project.config_files": "/Users/paulo.leite/java-socrates/java-device_agent_printing/docker-compose.yml",
"com.docker.compose.project.working_dir": "/Users/paulo.leite/java-socrates/java-device_agent_printing",
"com.docker.compose.service": "cups",
"com.docker.compose.version": "2.13.0"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "4c7a21bda72bf57ac7d1530055bae7e36ffbe05f829f3a615c1912bc5727eabb",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"631/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "631"
}
]
},
"SandboxKey": "/var/run/docker/netns/4c7a21bda72b",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"java-device_agent_printing_default": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"cups",
"cups",
"1941403add06"
],
"NetworkID": "5c6e3d84a70ea3c22d77fd07f6b00d791f43c9f6fb79fb0a81beee578e4bc170",
"EndpointID": "a4e3ff11432113a07df30099c8c39dbc7992d3809974f95cc7bf12c395d29f20",
"Gateway": "172.29.0.1",
"IPAddress": "172.29.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:1d:00:02",
"DriverOpts": null
}
}
}
}
]
If I run curl again but this time with the container’s address:
curl 172.29.0.2:631
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="/cups.css" type="text/css">
<link rel="shortcut icon" href="/apple-touch-icon.png" type="image/png">
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=9">
<meta name="viewport" content="width=device-width">
<title>Home - CUPS 2.3.3op2</title>
</head>
<body>
<div class="header">
<ul>
<li><a href="http://www.cups.org/" target="_blank">CUPS.org</a></li>
<li><a class="active" href="/">Home</a></li>
<li><a href="/admin">Administration</a></li>
<li><a href="/classes/">Classes</a></li>
<li><a href="/help/">Help</a></li>
<li><a href="/jobs/">Jobs</a></li>
<li><a href="/printers/">Printers</a></li>
</ul>
</div>
<div class="body">
<div class="row">
<h1>CUPS 2.3.3op2</h1>
<p>CUPS is the standards-based, open source printing system developed by <a href="http://www.apple.com/">Apple Inc.</a> for macOS<sup>®</sup> and other UNIX<sup>®</sup>-like operating systems.</p>
</div>
<div class="row">
<div class="thirds">
<h2>CUPS for Users</h2>
<p><a href="help/overview.html">Overview of CUPS</a></p>
<p><a href="help/options.html">Command-Line Printing and Options</a></p>
<p><a href="http://www.cups.org/lists.php?LIST=cups">User Forum</a></p>
</div>
<div class="thirds">
<h2>CUPS for Administrators</h2>
<p><a href="help/admin.html">Adding Printers and Classes</a></p>
<p><a href="help/policies.html">Managing Operation Policies</a></p>
<p><a href="help/network.html">Using Network Printers</a></p>
<p><a href="help/firewalls.html">Firewalls</a></p>
<p><a href="help/man-cupsd.conf.html">cupsd.conf Reference</a></p>
</div>
<div class="thirds">
<h2>CUPS for Developers</h2>
<p><a href="help/cupspm.html">CUPS Programming Manual</a></p>
<p><a href="help/api-filter.html">Filter and Backend Programming</a></p>
<p><a href="http://www.cups.org/lists.php?LIST=cups-devel">Developer Forum</a></p>
</div>
</div>
</div>
<div class="footer">CUPS and the CUPS logo are trademarks of <a href="http://www.apple.com">Apple Inc.</a> Copyright © 2007-2019 Apple Inc. All rights reserved.</div>
</body>
</html>
# curl 172.29.0.2:631/printers
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="/cups.css" type="text/css">
<link rel="shortcut icon" href="/apple-touch-icon.png" type="image/png">
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=9">
<meta name="viewport" content="width=device-width">
<style>html{display:none;}</style>
<script type="text/javascript"><!--
/* Only display document if we are not in a frame... */
if (self == top) {
document.documentElement.style.display = 'block';
} else {
top.location = self.location;
}
/* Show an error if cookies are disabled */
function check_cookies() {
if (!navigator.cookieEnabled) {
document.getElementById('body').innerHTML = 'This page uses cookies to prevent common cross-site attacks. Please enable cookies in your browser.';
}
}
--></SCRIPT>
<title>Printers - CUPS 2.3.3op2</title>
</head>
<body onload="check_cookies();">
<div class="header">
<ul>
<li><a href="http://www.cups.org/" target="_blank">CUPS.org</a></li>
<li><a href="/">Home</a></li>
<li><a href="/admin">Administration</a></li>
<li><a href="/classes/">Classes</a></li>
<li><a href="/help/">Help</a></li>
<li><a href="/jobs/">Jobs</a></li>
<li><a class="active" href="/printers/">Printers</a></li>
</ul>
</div>
<div class="body">
<div class="row">
<h1>Printers</h1>
<FORM ACTION="/printers/" METHOD="GET">
<P ALIGN="CENTER"><B>Search in
Printers:</B>
<INPUT TYPE="SEARCH" NAME="QUERY" VALUE="" SIZE="40" PLACEHOLDER="" AUTOSAVE="org.cups.printers" RESULTS="20"> <INPUT
TYPE="SUBMIT" VALUE="Search"> <INPUT TYPE="SUBMIT" NAME="CLEAR" VALUE="Clear"></P>
</FORM>
<P ALIGN="CENTER">Showing 1 of 1 printer.</P>
<TABLE CLASS="list" SUMMARY="Printer List">
<THEAD>
<TR><TH>Queue Name</TH><TH>Description</TH><TH>Location</TH><TH>Make and Model</TH><TH>Status</TH></TR>
</THEAD>
<TBODY>
<TR><TD><A HREF="/printers/Virtual_PDF_Printer">Virtual_PDF_Printer</A></TD><TD>Virtual PDF Printer</TD><TD></TD><TD>Local Raw Printer</TD><TD>Idle</TD></TR>
</TBODY>
</TABLE></DIV>
</div>
</div>
<div class="footer">CUPS and the CUPS logo are trademarks of <a href="http://www.apple.com">Apple Inc.</a> Copyright © 2007-2019 Apple Inc. All rights reserved.</div>
</body>
</html>
If both containers were on the same network wouldn’t a curl localhost:631 work?