The error occurred when I'm following in28minutes's course - "Microservices" on Udemy. When using maven build command "spring-boot:build-image -DskipTest" to create a Docker image, it gives the error. After digging a while, I found out that the default one is a socket without TCP on Ubuntu.
I had to allow Docker to accept requests from remote hosts by configuring it to listen on an IP address and port as well as the UNIX socket following steps from here.
1.Edit the docker.service file.
sudo systemctl edit docker.service
Lets say we want to listen for connections from any remote host on port 2376
2. we need to add this lines:
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376
3. Write the changes (ctrl-o) and exit (ctrl-x).
4. Reload the systemctl configuration.
sudo systemctl daemon-reload
5. Restart the Docker service.
sudo systemctl restart docker.service
6. Verify the dockerd daemon listening on the configured port using the netstat command.
sudo netstat -lntp | grep dockerd
here is the sequence:
Also I needed to run the created Docker image with sudo.
Another one usefule is creating symlink: sudo ln -s -f /home/[yourusername]/.docker/desktop/docker.sock /var/run/docker.sock
No comments:
Post a Comment