Setting up Mollyguard (often mistakenly called "MollySocket") via Portainer is a great way to add an extra layer of protection to your Docker environment by controlling container startup permissions.
⚠️ Clarification : There is no official Docker project or tool called "MollySocket". You're likely referring to Mollyguard , a lightweight security tool that acts as a gatekeeper for Docker container execution — it prevents containers from starting unless explicitly allowed.
✅ What You’ll Do:
Install Portainer (skip if already installed).
Add Mollyguard to Portainer.
Configure Mollyguard to protect container creation/start.
🚀 Step-by-Step Instructions
🔧 1. Install Portainer (if not installed)
You can install Portainer using Docker:
bash Copy code
docker volume create portainer_data
docker run -d -p 9000:9000 --name=portainer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:latest
Then access it in your browser at:
👉 http://localhost:9000
Follow the setup wizard to create an admin account.
📦 2. Deploy Mollyguard via Portainer
Option A: Pull & Run Manually via Portainer UI
Go to Portainer Web UI → Containers → Add Container
Fill in details:
Image : ghcr.io/stevenaldinger/mollyguard:latest
Name : mollyguard
Restart policy : Always or Unless-stopped
Ports : Leave empty (unless you want to expose API)
Volumes :
/var/run/docker.sock:/var/run/docker.sock (so Mollyguard can control Docker)
Click Deploy the container
⚙️ 3. Configure Docker to Use Mollyguard as a Proxy
To make Mollyguard act as a gatekeeper, you need to redirect all Docker CLI and API calls through it .
Stop Docker Service Temporarily
bash Copy code
sudo systemctl stop docker
Edit Docker Daemon Config (/etc/docker/daemon.json):
json Copy code
{
"hosts": ["unix:///var/run/docker-proxy.sock", "tcp://0.0.0.0:2375"],
"proxies": {
"http-proxy": "/var/run/docker.sock"
}
}
⚠️ Wait! Docker doesn’t natively support proxying through Mollyguard like this. We need to replace the Docker socket with Mollyguard.
Instead, do this:
bash Copy code
sudo mv /var/run/docker.sock /var/run/docker.sock.bak
sudo ln -s /var/run/docker-proxy.sock /var/run/docker.sock
❌ Above won't work either — because Mollyguard itself needs to sit in front of the Docker socket .
✅ Correct Way: Point Docker CLI to Mollyguard
Actually, you don’t change Docker daemon config . Instead:
You run Mollyguard on the host and bind-mount /var/run/docker.sock
Then use mollyguard CLI or API to approve/block containers
But to use it as a gatekeeper, it’s better to replace the Docker socket path temporarily with a Mollyguard-managed one.
Better method:
Stop Docker:
bash Copy code
sudo systemctl stop docker
Start Mollyguard manually (for testing):
bash Copy code
docker run --rm -it \
--privileged \
-v /var/run/docker.sock:/var/run/docker.sock \
ghcr.io/stevenaldinger/mollyguard:latest
But again, this is not persistent.
🔁 4. Use Portainer to Manage Mollyguard (Recommended)
Since Portainer runs as a container, and Mollyguard also is a container, to make Mollyguard control the Docker socket used by Portainer (and system), you need to:
Mount Docker Socket into Mollyguard Only
Instead of replacing system socket, create a new socket path and have Mollyguard listen there.
But that's advanced. Easier setup:
Run Mollyguard on the host machine (outside Portainer) with:
bash Copy code
docker run -d \
--name=mollyguard \
-v /var/run/docker.sock:/var/run/docker.sock \
-p 8080:8080 \
ghcr.io/stevenaldinger/mollyguard:latest
Configure Docker CLI to talk to Mollyguard:
Set env variable to use Mollyguard API:
bash Copy code
export DOCKER_HOST=http://localhost:8080
Now when you run docker ps, it will ask Mollyguard to allow it.
(Optional) Use Portainer to monitor containers — but don’t let Portainer manage Docker directly if Mollyguard is gatekeeping .
🛡️ 5. Using Mollyguard
Once Mollyguard is running and Docker CLI is pointed to it:
Any docker command will be blocked unless allowed.
Mollyguard will prompt for approval (via CLI or web UI).
You can configure policies to auto-allow certain containers.
For Web UI access, visit:
👉 http://localhost:8080
🧠 Tips
Don’t point Portainer to Mollyguard-controlled Docker socket unless you want Portainer requests blocked too.
Best use: Run Portainer normally, and use Mollyguard separately to control docker CLI and automation tools.
You can whitelist images/commands in Mollyguard config.
🧪 Example Flow
bash Copy code
# Try running a container
docker run hello-world
# Mollyguard blocks it:
# ERROR: Request blocked. Approve at http://localhost:8080
Go to Mollyguard web UI → Approve → Container runs.
📘 Resources
✅ Summary
Task Instruction Install Portainer Use Docker CLI or Docker Compose Run Mollyguard As a container with Docker socket access Control Docker Point CLI to Mollyguard’s HTTP API Portainer Keep it isolated from Mollyguard socket (optional)
If you meant a different tool named "MollySocket", please clarify and I’ll update the guide.