I’d like to use this droplet as remote Docker server for VSCode development, I have Windows 11 with WSL2. If it is easy, I’d like next level - set up Windows Docker Desktop pointed to your(my) server
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!
Heya,
By default, Docker only listens to local connections for security. You’ll need to configure it to accept remote connections.
sudo nano /etc/docker/daemon.json
Add the following configuration, replacing YOUR_IP
with your droplet’s IP address:
{
"hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"],
"tls": true,
"tlsverify": true,
"tlscacert": "/etc/docker/certs/ca.pem",
"tlscert": "/etc/docker/certs/server-cert.pem",
"tlskey": "/etc/docker/certs/server-key.pem"
}
Create and Install TLS Certificates: You’ll need to generate TLS certificates to securely connect to Docker remotely.
On the droplet:
mkdir -p /etc/docker/certs
cd /etc/docker/certs
openssl genrsa -out ca-key.pem 4096
openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem
openssl genrsa -out server-key.pem 4096
openssl req -subj "/CN=YOUR_IP" -sha256 -new -key server-key.pem -out server.csr
openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem
after that restart Docker
sudo systemctl restart docker
Expose daemon on tcp://localhost:2375 without TLS
.Ctrl+Shift+P
), then select Remote-Containers: Attach to Running Container.Now, in VSCode, open the Docker extension and select Connect to Host using the IP of your droplet with port 2376
. With Docker Desktop configured for remote development, you can seamlessly work with containers on your DigitalOcean server while managing from your local machine.
Let me know if you’d like help with further configurations or any troubleshooting tips!
Heya,
The instructions for the setup are pretty much covered by KFSys. Here are some important topics to note as well.
Docker Desktop on WSL2 offers native Docker support for a seamless experience on Windows. You can develop locally on Docker Desktop and only push containers to the droplet when needed. This approach keeps development fast and responsive, with the option to deploy easily on your DigitalOcean instance.
You can use TLS to encrypt connections to the Docker API. This requires creating certificates for the Docker daemon and configuring Docker Desktop and VSCode to use these certificates. This setup keeps your connection secure but adds a bit of complexity to the initial configuration.
Rather than exposing the Docker API on an open port, set up an SSH tunnel. You can create an SSH connection from your local machine to your droplet and then connect VSCode and Docker Desktop through this tunnel. This keeps Docker accessible only to your local machine, reducing exposure risks.
For example, you can create an SSH tunnel like this on your Windows machine:
ssh -L 2375:localhost:2375 root@your_droplet_ip
Then, in VSCode or Docker Desktop, point to tcp://localhost:2375
.
Regards
Hey!
Yep, that is doable. You would need to first set up remote access for Docker daemon on your Droplet as described here:
Here is a quick overview of what you need to do:
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04
sudo nano /etc/docker/daemon.json
<your_droplet_ip>
with the Droplet’s IP address:
{
"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]
}
sudo systemctl restart docker
Note: By enabling remote access over TCP, your Docker server is open to anyone with your IP and port 2375. You should use a firewall or SSH tunneling to secure the connection. Here’s how to set up a firewall on DigitalOcean and close port 2375 for public access and only allow your IP:
https://docs.digitalocean.com/products/networking/firewalls/
.bashrc
or .zshrc
in WSL2 and add this line to point Docker commands to your remote server:
export DOCKER_HOST=tcp://<your_droplet_ip>:2375
source ~/.bashrc
{
"hosts": ["tcp://<your_droplet_ip>:2375"]
}
This setup allows VS Code and Docker Desktop to communicate with the remote Docker instance on your DigitalOcean Droplet for containerized development.
Make sure to secure the Docker socket, especially if using it over the internet, by setting up a firewall or considering SSH tunneling for added security!
- Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.