root@VM-4-3-ubuntu:~# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2024-07-26 18:23:30 CST; 4min 23s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 2150092 (dockerd)
Tasks: 41
Memory: 27.7M
CPU: 507ms
CGroup: /system.slice/docker.service
├─2150092 /usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:16875 --containerd=/run/containerd/containerd.sock
├─2151429 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8000 -container-ip 172.17.0.2 -container-port 8000
├─2151435 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8000 -container-ip 172.17.0.2 -container-port 8000
├─2151441 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9443 -container-ip 172.17.0.2 -container-port 9443
└─2151451 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 9443 -container-ip 172.17.0.2 -container-port 9443
root@VM-4-3-ubuntu:~# vim /lib/systemd/system/docker.service
# 修改此文件,只需要修改ExecStart的参数:添加 -H tcp://0.0.0.0:自己定义一个端口号,如下:
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:16875 --containerd=/run/containerd/containerd.sock
重启docker之后,通过curl验证
root@VM-4-3-ubuntu:~# curl localhost:16875/images/json
[{"Containers":-1,"Created":1713743470,"Id":"sha256:a3f85c245ec38eacdd9b749659c351a1d2601a08fa784c9c4b7200b83c64eb0c","Labels":{"com.docker.desktop.extension.api.version":">= 0.2.2","com.docker.desktop.extension.icon":"https://portainer-io-assets.sfo2.cdn.digitaloceanspaces.com/logos/portainer.png","com.docker.extension.additional-urls":"[{\"title\":\"Website\",\"url\":\"https://www.portainer.io?utm_campaign=DockerCon&utm_source=DockerDesktop\"},{\"title\":\"Documentation\",\"url\":\"https://docs.portainer.io\"},{\"title\":\"Support\",\"url\":\"https://join.slack.com/t/portainer/shared_invite/zt-txh3ljab-52QHTyjCqbe5RibC2lcjKA\"}]","com.docker.extension.detailed-description":"<p data-renderer-start-pos=\"226\">Portainer’s Docker Desktop extension gives you access to all of Portainer’s rich management functionality within your docker desktop experience.</p><h2 data-renderer-start-pos=\"374\">With Portainer you can:</h2><ul><li>See all your running containers</li><li>Easily view all of your container logs</li><li>Console into containers</li><li>Easily deploy your code into containers using a simple form</li><li>Turn your YAML into custom templates for easy reuse</li></ul><h2 data-renderer-start-pos=\"660\">About Portainer </h2><p data-renderer-start-pos=\"680\">Portainer is the worlds’ most popular universal container management platform with more than 650,000 active monthly users. Portainer can be used to manage Docker Standalone, Kubernetes, Docker Swarm and Nomad environments through a single common interface. It includes a simple GitOps automation engine and a Kube API. </p><p data-renderer-start-pos=\"1006\">Portainer Business Edition is our fully supported commercial grade product for business-wide use. It includes all the functionality that businesses need to manage containers at scale. Visit <a class=\"sc-jKJlTe dPfAtb\" href=\"http://portainer.io/\" title=\"http://Portainer.io\" data-renderer-mark=\"true\">Portainer.io</a> to learn more about Portainer Business and <a class=\"sc-jKJlTe dPfAtb\" href=\"http://portainer.io/take-3?utm_campaign=DockerCon&utm_source=Docker%20Desktop\" title=\"http://portainer.io/take-3?utm_campaign=DockerCon&utm_source=Docker%20Desktop\" data-renderer-mark=\"true\">get 3 free nodes.</a></p>","com.docker.extension.publisher-url":"https://www.portainer.io","com.docker.extension.screenshots":"[{\"alt\": \"screenshot one\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-1.png\"},{\"alt\": \"screenshot two\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-2.png\"},{\"alt\": \"screenshot three\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-3.png\"},{\"alt\": \"screenshot four\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-4.png\"},{\"alt\": \"screenshot five\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-5.png\"},{\"alt\": \"screenshot six\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-6.png\"},{\"alt\": \"screenshot seven\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-7.png\"},{\"alt\": \"screenshot eight\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-8.png\"},{\"alt\": \"screenshot nine\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-9.png\"}]","io.portainer.server":"true","org.opencontainers.image.description":"Docker container management made simple, with the world’s most popular GUI-based container management platform.","org.opencontainers.image.title":"Portainer","org.opencontainers.image.vendor":"Portainer.io"},"ParentId":"","RepoDigests":["portainer/portainer-ce@sha256:4a1ceadd7f7898d9190ee0a6d22234c4323aefd80e796e84f5e57127f74370f1"],"RepoTags":["portainer/portainer-ce:latest"],"SharedSize":-1,"Size":292768236},{"Containers":-1,"Created":1683046167,"Id":"sha256:d2c94e258dcb3c5ac2798d32e1249e42ef01cba4841c2234249495f87264ac5a","Labels":null,"ParentId":"","RepoDigests":["hello-world@sha256:1408fec50309afee38f3535383f5b09419e6dc0925bc69891e79d84cc4cdcec6"],"RepoTags":["hello-world:latest"],"SharedSize":-1,"Size":13256}]
具体接口路径,需要根据docker版本查看官网的介绍了