Docker portainer tcp 127.0.0.1:2375: connect: connection refused - windows

I am trying to use portainer/portainer:1.24.1-alpine.
My docker in my windows, my container is linux.
portainer | 2020/09/04 12:42:57 Get http://localhost:2375/_ping: dial tcp 127.0.0.1:2375: connect: connection refused
My docker-compose.yml, i tried it on linux as host and #command: -H unix:///var/run/docker.sock works fine, but now I am using do windows as HOST.
version: "3.7"
services:
web:
container_name: portainer
image: portainer/portainer:1.24.1-alpine
#command: -H unix:///var/run/docker.sock << i am not using linux as HOST.
command: -H tcp://localhost:2375
restart: always
ports:
- 9999:9000
volumes:
# - /var/run/docker.sock:/var/run/docker.sock
- web_data:/data
volumes:
web_data:
driver: local
What should I used on line command: -H ????????

Related

Docker containers not logging to loki using loki log driver

I'm trying to use the loki log driver in a docker container on an AWS ec2 host. The config below works fine on my own ubuntu 20.04 machine but not in an ubuntu 16.04 ec2 host. iptables has a loopback rule and the appropriate docker port for loki, :3100. I even opened up that port in the security group. The docker version is 20.10.2.
I have tried to use localhost:3100, the hostname:3100, also the docker container name. I have a bridge network and don't want to use a host network. I also don't want to use the container IP address.
Nothing in this SO question works for me. How to access host port from docker container
Here is my docker-compose.yaml which works on my local machine but not in ec2.
the tools container is a go html server. The tools and loki containers are on the same host.
I can post a log to loki from an alpine container using curl to URL http://loki:3100/loki/api/v1/push but not from my tools container. I can connect with telnet but curl times out.
version: '3.3'
networks:
traefik:
external: true
loki: {}
services:
tools:
build: .
container_name: tools
restart: always
networks:
- traefik
- loki
extra_hosts:
- "host.docker.internal:host-gateway"
logging:
driver: loki
options:
loki-url: http://loki:3100/loki/api/v1/push
loki-external-labels: job=tools
labels:
...
Here is my loki docker-compose.yaml
version: "3.8"
networks:
traefik:
external: true
loki: {}
volumes:
loki_data:
services:
loki:
container_name: "loki"
image: grafana/loki:2.1.0
restart: always
networks:
- traefik
- loki
ports:
- 3100:3100
volumes:
- type: volume
source: loki_data
target: /data
- type: bind
source: ./config/s3-loki-bolt-conf.yml
target: /etc/loki/local-config.yaml
command: -config.file=/etc/loki/local-config.yaml
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
the docker plugin is installed
docker plugin ls
ID NAME DESCRIPTION ENABLED
a03c22e8375e loki:latest Loki Logging Driver true
sudo journalctl -u docker.service | grep loki is giving me this error.
08 06:46:06 docker1 dockerd[30842]: time="2021-02-08T06:46:06-08:00" level=info msg="level=warn ts=2021-02-08T14:46:06.586642758Z caller=client.go:322 container_id=5a5fbd8a7077243de9db74f549ab619f783eda978ee234651ad1849263a534fe component=client host=localhost:3100 msg=\"error sending batch, will retry\" status=-1 error=\"Post \\\"http://localhost:3100/loki/api/v1/push\\\": context deadline exceeded\"" plugin=fef8734ec8cc2d252f8c4e73e3e91fe8293d2847c7ce1d6df2fb2172a1c288ce

Windows10 docker: Grafana not able to access influxdb-502 Bad Gateway

I have installed two containers(influxdb and grafana) inside docker.
Two containers up and running. Able to access grafana(http://localhost:3000/datasources/edit/1/) and influxdb(http://localhost:8086/query?q=show%20databases) urls from browser.
But when we configure influxdb in grafana, grafana api throwing 502: Bad Gateway.
Grafana log message
t=2020-12-23T23:53:36+0000 lvl=eror msg="Data proxy error" logger=data-proxy-log userId=1 orgId=1 uname=admin path=/api/datasources/proxy/1/query remote_addr=xxx.xx.x.x referer=http://localhost:3000/datasources/edit/1/ error="http: proxy error: dial tcp localhost:8086: connect: connection refused"
t=2020-12-23T23:53:36+0000 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=GET path=/api/datasources/proxy/1/query status=502 remote_addr=1xxx.xx.x.x time_ms=26 size=0 referer=http://localhost:3000/datasources/edit/1/
Docker Compose file:
version: “2”
services:
grafana:
image: grafana/grafana
container_name: grafana
restart: always
ports:
3000:3000
volumes:
grafana_storage:/var/lib/grafana_storage
networks:
ranga_docker_network
influxdb:
image: influxdb
container_name: influxdb
restart: always
ports:
8086:8086
volumes:
influxdb_storage:/var/lib/influxdb_storage
networks:
ranga_docker_network
environment:
INFLUXDB_DB=telegraf
INFLUXDB_USER=telegraf
INFLUXDB_ADMIN_ENABLED=true
INFLUXDB_ADMIN_USER=admin
INFLUXDB_ADMIN_PASSWORD=telegraf1234
networks:
ranga_docker_network:
volumes:
grafana_storage:
influxdb_storage:
Docker network also up and running.
C:\WINDOWS\system32>docker network ls
NETWORK ID NAME DRIVER SCOPE
f42bea59b834 bridge bridge local
5ae575311d19 host host local
d7f57802a04c monitoring_default bridge local
2419751561dd monitoring_monitoring bridge local
4829f3a73843 monitoring_ranga_docker_network bridge local
4962bd901e12 none null local
ad245f671c22 ranga_docker_network bridge local
Thanks,
Ranga Rao
Issue Root cause: Connect VPN but didn't restart Docker daemon.
Resolution: Restart Docker daemon after connecting VPN.

Can't connect to Docker sql for Windows by hostname

I have next docker compose file (part of it)
version: '3.7'
services:
# DB Server ==========================================================================================================
mssqlsimple:
image: microsoft/mssql-server-windows-developer:2017-latest
volumes:
- ".\\Prm.DbContext.Application\\FullInit:C:\\data"
container_name: pbpmssqlsimple
ports:
#- "1403:1433"
- target: 1433
published: 1403
protocol: tcp
mode: host
networks:
- backend
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: "SP_116b626d-ed7e-4f5d123#"
...
after command docker-compose up i have instance of sql server and can to connect to it by IP (172.21.69.132) or alias id (0338726df5ba) from docker config.
but i can't connect by host name mssqlsimple (or pbpmssqlsimple)
fragment config json
I tried to do it, but failed
disable windows firewall
connect with port mssqlsimple, 1403
used simple syntax for ports "1403:1433"
Tell me please how to solve my problem

traefik proxy for docker container running in host network

i am running traefik as a proxy in docker container
i am using DockerToolBox in windows 10
the traefik proxy was able to recognize the service app which is running in 127.0.0.1, but the service app is actually running in docker host = 192.168.99.x ip
version: '3'
services:
reverse_proxy:
image: traefik
command: --api --docker
ports:
- "81:80"
- "8081:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- backend
whoami:
image: containous/whoami
labels:
- "traefik.frontend.rule=Host:whoami.default"
- "traefik.enable=true"
- "traefik.port=80"
network_mode: host
networks:
backend:
driver: bridge
in the Traefik dashboard http://192.168.99.100:8081
it shows http://127.0.0.1:80 for whoami service
instead of http://192.168.99.100:80
any help would be appreciated.
i want network_mode: host to pick 192.168.99.100 instead of 127.0.0.1
As traefik official documentation says, when resolving service IP, first it
try a lookup of host.docker.internal
and second
if the lookup was unsuccessful, fall back to 127.0.0.1
This means we can just add a host in the traefik container, using --add-host {docker0_IP}(it's the bridge's IP, you can easily use docker inspect {NAME_OF_TRAEFIK} and find the IP of Gateway(for me, it's 172.18.0.1). If you use docker-compose, you can use add following lines to your definition of traefik:
extra_hosts:
- host.docker.internal:{docker0_IP}
Also, I find that it's ok to use the IP my eth0 IP, which means the IP of your LAN(for me, it's 192.168.0.20).
Then, recreate traefik and everything works like a daisy.

Can't reach server inside docker container from host

I am hosting a mysql server and a go http server in docker. I am unable to hit the http server from my host machine. My host machine is a mac.
I have tried using localhost:8080 and ipofserver:8080. I get the ip from the docker inspect. I am able to connect to my mysql server from my host, but i can't hit the server from the host.
Here is my docker ps output.
0.0.0.0:8080->8080/tcp
0.0.0.0:3306->3306/tcp, 33060/tcp
Below are my details:
Docker Desktop version 2.0.0.3.
docker-compose
version: '3.1'
services:
mysql:
image: mysql:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: mydb
volumes:
- mysql:/var/lib/mysql
ports:
- "3306:3306"
networks:
- mynetwork
server:
image: server:latest
networks:
- mynetwork
ports:
- "8080:8080"
volumes:
mysql: ~
networks:
mynetwork:
driver: "bridge"
mysql dockerfile
FROM mysql:8.0.16
COPY ./scripts/mysql/dbgen-v1.sql /docker-entrypoint-initdb.d/
EXPOSE 3306
server dockerfile
FROM golang:1.12.5
WORKDIR a/go/path
COPY . .
ENV GOBIN=/usr/local/bin
RUN go get github.com/go-sql-driver/mysql
RUN go get github.com/iancoleman/strcase
RUN go get github.com/jmoiron/sqlx
RUN go get github.com/spf13/cobra
RUN go get github.com/gorilla/websocket
RUN go get github.com/spf13/viper
RUN go install -v cmd/project/main.go
EXPOSE 8080
CMD ["main"]
(This answer is based on the chat we had in the comments)
In order to expose the web server from inside the container to the host it needs to bind to 0.0.0.0 and not to 127.0.0.1. Using 0.0.0.0 ensures that the web server binds to the bridge interface that can be accessed from the host side.
Relevant Docker docs: https://docs.docker.com/v17.09/engine/userguide/networking/default_network/binding/

Resources