Skip to content

Instantly share code, notes, and snippets.

@SeanSobey
Last active June 12, 2024 07:40
Show Gist options
  • Save SeanSobey/344edd228922ffd4266ae7d451421ab6 to your computer and use it in GitHub Desktop.
Save SeanSobey/344edd228922ffd4266ae7d451421ab6 to your computer and use it in GitHub Desktop.
Portainer Setup on Windows 10

Portainer on Windows 10

Here I have 2 methods for running portainer on windows, a quick, preferred method only requiring a fairly recent version of docker, or a more complicated method to try if that does not work.

Using host.docker.internal

This setup will let you run Portainer on windows by using the host.docker.internal endpoint (docker.for.win.localhost is depricated since docker version 3.2.1, but older versions may use this instead).

Please note:

  • This will expose your docker API, without TLS, publicly from your machine.
  • For more advanced config see the portainer docs.

Step 1 Enable docker without TLS

Docker settings -> General -> Expose docker daemon on tcp://...

Step 2 Run Portainer Image

The only trick here is to use this endpoint: tcp://host.docker.internal:2375 (tcp://docker.for.win.localhost:2375 is depricated).

Create portainer volume

Powsershell (admin):

docker volume create portainer_data

Create portainer container

With No Auth
docker run -d -p 3040:9000 --name portainer --restart=always -v portainer_data:/data portainer/portainer --no-auth -H tcp://host.docker.internal:2375
With Auth
docker run -d -p 3040:9000 --name portainer --restart=always -v portainer_data:/data portainer/portainer -H tcp://host.docker.internal:2375

Go to http://localhost:3040

To remove and revert all changes

Powsershell (admin):

docker stop portainer

docker rm portainer

docker rmi portainer/portainer

docker volume rm portainer_data

Using a loopback address (Fallback method)

This setup will let you run Portainer on windows by using a loopback address.

Please note:

  • Working with (current) Docker version 2.1.0.1, Windows 10 Build 18362.
  • YOU NEED TO BE ON LINUX CONTAINERS, this will not work on windows containers.
  • This will expose your docker API, without TLS, publicly from your machine.
  • For more advanced config see the portainer docs.

Step 1 Enable docker without TLS

Docker settings -> General -> Expose docker daemon on tcp://...

Find your docker API address

ipconfig -> Ethernet adapter vEthernet (DockerNAT): -> IPv4 Address -> eg: 10.0.75.1

This will be referred to as $DockerAddress.

Step 2 Create Looback Address

Powsershell (admin):

netsh interface portproxy add v4tov4 listenaddress=$DockerAddress listenport=2375 connectaddress=127.0.0.1 connectport=2375

Step 3 Allow Loopback through Firewall

Powsershell (admin):

netsh advfirewall firewall add rule name="Docker" dir=in action=allow protocol=TCP localport=2375 enable=yes profile=domain,private,public

OR, Manual version, create new firewall rule:

Firewall inbound rule:
	Rule Type: Port
	Protocol and Ports: TCP, 2375
	Action: Allow
	Profile: Domain, Private & Public
	Name: Docker

Edit Rule
	Scope, Remote IP address: 127.0.0.1

Step 4 Test Loopback

If the above steps were done correctly you should be able to see the docker API exposed on http://127.0.0.1:2375/ and http://10.0.75.1:2375/ (will just return a {"message":"page not found"} response).

Step 5 Run Portainer Image

Create portainer volume

Powsershell (admin):

docker volume create portainer_data

Create portainer container

With Auth
docker run -d -p 3040:9000 --name portainer --restart=always -v portainer_data:/data portainer/portainer

Go to http://localhost:3040 and add your endpoint (endpoint is: $DockerAddress:2375)

With No Auth

Powsershell (admin):

docker run -d -p 3040:9000 --name portainer --restart=always -v portainer_data:/data portainer/portainer --no-auth -H tcp://$DockerAddress:2375

Go to http://localhost:3040

To remove and revert all changes

Powsershell (admin):

docker stop portainer

docker rm portainer

docker rmi portainer/portainer

docker volume rm portainer_data

netsh interface portproxy reset

netsh advfirewall firewall delete rule name="Docker"
@edwinhuish
Copy link

@SeanSobey Thank you.

But I found another way as below:

version: "3"
services:
  portainer:
    image: portainer/portainer:latest
    container_name: portainer
    network_mode: "bridge"
    restart: unless-stopped
    ports:
      - 9000:9000
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - D:\docker\portainer\data:/data

The diffrent is /var/run/docker.sock:/var/run/docker.sock, it works fine for me.

You could use the docker run way, but I prefer docker-compose way

@Th0masAAnderson
Copy link

Hello togehter,
just a stupid question from a newbie to Docker and Portainer. I have to take over an already existing, installed but not configured working installation from Portainer on Windows Server 2019. How can I change the working, data and or, most important, the image directory without installing all new? I can't find a solution on Google since days.

Thanks in adavnce.
Thomas

@edwinhuish
Copy link

@Th0masAAnderson You could change the image directory as below.

image

@rufdev
Copy link

rufdev commented Jul 29, 2020

this was the best guide so far for windows 10. i never got to install portainer using wsl2. the end point is lost after restarting docker but with this guide it worked perfectly.

@paeblits
Copy link

paeblits commented Sep 17, 2020

Didn't see a docker-compose solution so I'm pasting here. You simply need to add a command to your service.

command:
    "-H"
    "tcp://docker.for.win.localhost:2375"`

@oscarsal433
Copy link

Works for me thanks!

@Artekus
Copy link

Artekus commented Mar 15, 2021

tcp://docker.for.win.localhost:2375 has been been removed, it is now tcp://host.docker.internal:2375

docker/for-win#10619 (comment)

@SeanSobey
Copy link
Author

tcp://host.docker.internal:2375

Thanks, updated

@peyrusse
Copy link

It worked for me with tcp://host.docker.internal:2375. Thanks.

@shahidcodes
Copy link

Portainer has official docs on how to use with wsl
https://docs.portainer.io/v/ce-2.9/start/install/server/docker/wsl
no issue so far

@chaoscreater
Copy link

docker: Error response from daemon: invalid volume specification: 'portainer_data:/data'.

@NemchinovSergey
Copy link

Thank you, it worked for me on Windows 10 (build 1809) WSL 1 with tcp://localhost:2375 using a loopback address.

Note: the flag --no-auth is unknown and the container doesn't start with it. I removed it when started the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment