Tecnativa / docker-socket-proxy

Proxy over your Docker socket to restrict which requests it accepts
Apache License 2.0
1.41k stars 161 forks source link

Unable start/stop/restart/remove container from remote host via Portainer #78

Closed corasaniti closed 1 year ago

corasaniti commented 1 year ago

Hi, I love this project congratulations...

From a remote host I would like to be able to start/stop/restart/remove the containers via Portainer but I get the following error

Failure
Request failed with status code 403

This is my docker run

docker container run \
    -d --privileged \
    --name dockerproxy \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -p 0.0.0.0:2375:2375 \
    -e BUILD=1 \
    -e COMMIT=1 \
    -e CONFIGS=1 \
    -e CONTAINERS=1 \
    -e DISTRIBUTION=1 \
    -e EXEC=1 \
    -e GRPC=1 \
    -e IMAGES=1 \
    -e INFO=1 \
    -e NETWORKS=1 \
    -e NODES=1 \
    -e PLUGINS=1 \
    -e SERVICES=1 \
    -e SESSION=1 \
    -e SWARM=1 \
    -e SYSTEM=1 \
    -e TASKS=1 \
    -e VOLUMES=1 \
    tecnativa/docker-socket-proxy

Thanks in advance PC

bartclone commented 1 year ago
corasaniti commented 1 year ago

@bartclone

  • Have you defined the socket as an endpoint? see https://docs.portainer.io/admin/environments/add/docker - see HAProxy #74 sure!! I already able to connect on remote host via Portainer and display containers, but I'm not able start/stop/remove and create containers

  • Firewall active on the remote host? nothing firewall on remote host

thanks

bartclone commented 1 year ago

@corasaniti have you tested / tried if start/stop/remove works when using the normal API of Portainer Agent?

corasaniti commented 1 year ago

@bartclone sure!!! I able start/stop/remove containers from localhost and Portainer, but I get this permission issue

Failure
Request failed with status code 403

I also added this env in my docker run, but doesnt works -e RESTART_ALLOWS=1

frxncodominguez commented 1 year ago

Hi, I don't know if you were able to solve this problem but I had the same problem and I solved it by adding this env POST=1 in the socket-proxy

corasaniti commented 1 year ago

@frxncodominguez thanks, adding this env POST=1 it worked for me...

chessmango commented 1 year ago

@frxncodominguez thanks, adding this env POST=1 it worked for me...

Thanks for confirming! Could you close this issue?

corasaniti commented 1 year ago

thanks, to @frxncodominguez , with adding this env POST=1 in docker run command worked for me...