Though this technique, which I am going to mention here, is considered little dangerous if your docker machine reside in a non-secured public or private network, so before following this tutorial blindly, work on the need and security of your system.
By default, docker daemon is local to its machine where it is installed because it is listening to machine's local port, we are going to exploit this feature only to make the docker daemon public.
Stop the docker service -
service docker stop
or
systemctl docker stop
and now check -
ps -ef | grep docker
if docker is still running, kill the docker process as below -
kill this process
kill -9 <docker process id>
now, start the docker with below arguments (you can use any port)-
dockerd -H tcp://0.0.0.0:2222
i.e-
[root@centos ~]# ps -ef | grep dockerd
root 76123 75648 0 09:37 pts/0 00:00:00 /usr/bin/dockerd-current -H tcp://0.0.0.0:2222
root 77046 75648 0 09:39 pts/0 00:00:00 grep --color=auto dockerd
by executing above command, we are forcing docker to listen to a TCP port 2222 which is open in the network.
To access this daemon, from local or network system, you have to make a slight change, set the below env variable -
DOCKER_HOST=tcp://<docker host machine ip>:2222
i.e-
[root@centos ~]# export DOCKER_HOST=tcp://centos.localhost:2222
[root@centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/ubuntu 18.04 3556258649b2 4 weeks ago 64.2 MB
Facebook Page Facebook Group Twitter Feed Telegram Group