DEV Community

Cover image for Run Docker Remotely with Portainer Instead of Docker Desktop
Cyril Sebastian
Cyril Sebastian

Posted on • Originally published at tech.cyrilsebastian.com

Run Docker Remotely with Portainer Instead of Docker Desktop

Managing Docker remotely, especially on a Linux server, is a powerful alternative to using Docker Desktop on your local machine. In this guide, we'll walk through how to:

  • Host and manage Docker containers remotely.
  • Use Portainer as a graphical interface to control Docker.
  • Replace Docker Desktop with a more flexible and lightweight remote workflow.

Whether you're a DevOps engineer, a cloud enthusiast, or simply exploring alternatives to Docker Desktop, this setup will enhance your productivity.


🧱 Why Portainer Instead of Docker Desktop?

Docker Desktop is great, but it has limitations:

  • Requires a GUI and lots of system resources.
  • Licensing costs for teams.
  • Tied to your local machine.

Portainer is:

  • Lightweight
  • Web-based
  • Platform-agnostic
  • Perfect for headless servers and remote access.

🗂 Step-by-Step Guide

1. Connect to Your Server

SSH into your remote server:

ssh your-user@your-server-ip
Enter fullscreen mode Exit fullscreen mode

Switch to root if necessary:

sudo -i
Enter fullscreen mode Exit fullscreen mode

2. Create a Directory for Docker Configs

Well organize Portainer and any other services under /opt/docker:

mkdir -p /opt/docker && cd /opt/docker
Enter fullscreen mode Exit fullscreen mode

3. Prepare portainer.yml File

Create a Docker Compose file for Portainer:

vim portainer.yml
Enter fullscreen mode Exit fullscreen mode

Paste the following content:

version: '3.8'

services:
  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
    restart: unless-stopped
    ports:
      - "9000:9000"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data

volumes:
  portainer_data:
Enter fullscreen mode Exit fullscreen mode

Save and exit (Ctrl + O, Enter, Ctrl + X).


4. Start Portainer

Now launch Portainer with:

docker compose -f portainer.yml up -d
Enter fullscreen mode Exit fullscreen mode

You should see:

 Container Portainer started
Enter fullscreen mode Exit fullscreen mode

To follow logs:

docker compose -f portainer.yml logs -f
Enter fullscreen mode Exit fullscreen mode

5. Access Portainer in a Browser

Open your browser and go to:

http://<your-server-ip>:9000
Enter fullscreen mode Exit fullscreen mode

You'll be prompted to set up an admin password and connect to your local Docker environment (it'll detect the Docker socket you mapped).


🔍 Confirm It's Working

To check if Portainer is running:

docker ps
Enter fullscreen mode Exit fullscreen mode

Expected output:

CONTAINER ID IMAGE PORTS NAMESxxxxxxx portainer/portainer-ce 0.0.0.0:9000->9000/tcp portainer
Enter fullscreen mode Exit fullscreen mode

You can also view logs anytime:

docker logs portainer
Enter fullscreen mode Exit fullscreen mode

Run Docker Remotely Like It's Local

You can run any Docker CLI commands remotely, without directly accessing your lab machine.

Option 1: Set a Permanent Remote Docker Context

Edit your .zshrc file on your Mac:

echo 'export DOCKER_HOST=ssh://username@remote_ip' >> ~/.zshrc source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Now, you can run any Docker CLI command like:

docker ps docker compose up -d docker logs <container>
Enter fullscreen mode Exit fullscreen mode

and it'll execute on the remote machine automatically. No ssh, no fuss.

Conclusion

You now have a clean and efficient way to manage Docker remotely without relying on Docker Desktop. Using Portainer , you gain:

  • A lightweight web UI
  • Easy container and image management
  • Portability across systems
  • Remote team-friendly access

This approach is ideal for remote development, headless servers, or teams building CI/CD and DevOps pipelines.

Top comments (0)