By default, the Docker daemon generates a socket (/var/run/docker.sock) file to process local process traffic without listening to any ports, so you can only use the Docker client locally or use the Docker API to do so.
If you want to operate a Docker host on another host, you need to have the Docker daemon listen to a port for remote communication.
Modify the Docker service startup configuration file, add an unused port number, and restart the Docker daemon.
- # Vim/etc/default/docker
- docker_opts= "-H 0.0.0.0:5555"
- # Service Docker Restart
Copy Code
Now that the Docker daemon is listening on port 5555, the Docker process can be accessed through that port on another host.
- # docker-h ip:5555 Images
Copy Code
But we found that there was a problem with Docker operating locally.
- # Docker Images
- FATA[0000] Cannot connect to the Docker daemon. Is ' docker-d ' running on this host?
Copy Code
This is because the Docker process only has remote access enabled, and local socket access is not turned on. We modify the/etc/default/docker and then reboot.
- # Vim/etc/default/docker
- docker_opts= "-H unix:///var/run/docker.sock-h 0.0.0.0:5555"
- # Service Docker Restart
Copy Code
The Docker process is now accessible both locally and remotely.
Docker Learning Notes (4)-Turn on Docker remote access