I’m trying to set up my local Docker CLI to communicate with a remote Docker Engine running on a DigitalOcean Droplet. Basically, I don’t have much resources on my local machine so I need to run some builds and runs on a remote Droplet.
I’d like to understand:
I’ve looked at the Docker documentation, but I’d love to hear from the community about practical tips, common pitfalls, and real-world use cases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey there!
One way of of doing this is, uou can connect your local Docker CLI to a remote Docker Engine by setting the
DOCKER_HOST
environment variable.Here’s how to do it:
Find the line that starts with
ExecStart
and modify it to include the-H
flag for the remote API:Save and restart Docker:
On your local machine, you can now connect to the remote engine by running:
For production setups, exposing the Docker API on an open port is risky. Here’s how to secure it:
Option 1: Use SSH Tunnels Create an SSH tunnel to your remote Droplet:
Then point your
DOCKER_HOST
tolocalhost
instead:Option 2: Use Certificates Configure Docker to use TLS certificates for authentication. The official Docker docs have step-by-step instructions for this.
Regarding the benefits, I would say that they are:
And for the downsides:
If you want to dive deeper into Docker, I’ve got a free eBook that might help: Introduction to Docker. It covers the basics of Docker, setting up environments, and much more.
Also, here is a great video that also covers the above!
Hope this helps!