I have a fresh AWS EC2 machine (Ubuntu 20.04 LTS server) which is a master of a Docker swarm. I am trying to deploy Portainer agent to monitor my stack remotely.
If I follow the official guide, issuing the commands:
docker network create portainer_agent_network
docker service create --name portainer_agent --network portainer_agent_network --publish mode=host,target=9001,published=9001 -e AGENT_CLUSTER_ADDR=tasks.portainer_agent --mode global --mount type=bind,src=//var/run/docker.sock,dst=/var/run/docker.sock --mount type=bind,src=//var/lib/docker/volumes,dst=/var/lib/docker/volumes --mount type=bind,src=/,dst=/host portainer/agent
I get the error:
Error: No such network: portainer_agent_network
Didn't I just create the mentioned network? What am I missing? Thanks in advance!
It seems that the network should be attachable. Create it with:
docker network create --driver=overlay --attachable portainer_agent_network
Related
I have a container running nifi (--name nifi) exposing port 8080 and another container running nifi registry (--name nifireg) exposing port 10808. I can get to both UI's, and I am able to connect nifi to the registry in the registry services by using the registry container's IP (172.17.0.5). These containers are also on a docker network called nifi-net. My issue is that the registry client is unable to talk to the registry when using the container name.
From the nifi I can ping by container IP as well as by name (ping nifireg), so there is some level of connectivity. But if I change the registry client to point to http://nifireg:180880 or even http://nifi-net.nifireg:18080 it clocks for a while and then eventually returns this error:
Unable to obtain listing of buckets: java.net.ConnectException: Connection refused (Connection refused)
What needs to be done to allow nifi to connect to the nifi registry using the container name?
EDIT: Here is how I set everything up:
docker run -d --name nifi -p 8080:8080 apache/nifi
docker run -d --name nifireg -p 18080:18080 apache/nifi-registry
I added the netorking after the fact, but that shouldn't be an issue.
docker network create nifi-net
docker network connect nifi-net nifi
docker network connect nifi-net nifireg
I don't understand why this solved the problem, but destroying the containers and recreating them with the --net nifi-net option at spin-up solved the problem.
docker run -d --name nifi --net nifi-net -p 8080:8080 apache/nifi
docker run -d --name nifireg --net nifi-net -p 18080:18080 apache/nifi-registry
The docs state that you can add them to a network after the fact, and I am able to ping from one container to the other using the name. I guess it's just a lesson that I need to use docker networking more.
I would suggest using docker-compose to manage the deployment since you can define the network once in docker-compose.yaml and not have to worry about it agian.
Plus it lets you learn about docker networking :P
I'm trying to set up gitlab CI on a windows 10 PC.
I have created a docker container for gitlab (volumes are docker volumes)
docker run --detach --name gitlab --hostname gitlab.mod --publish 4443:443 --publish 4480:80 --publish 8222:22 --volume gitlab-conf:/etc/gitlab --volume gitlab-logs:/var/log/gitlab --volume gitlab-data:/var/opt/gitlab gitlab/gitlab-ce
Another for the runner
docker run -d --name gitlab-runner -v gitlab-runner-conf:/etc/gitlab-runner gitlab/gitlab-runner:latest
registered
docker run --rm -t -i -v gitlab-runner-conf:/etc/gitlab-runner gitlab/gitlab-runner register --url "http://11.22.33.44:4480/" --registration-token "sEcrEttOkEnfOrgItlAb" --description "Runner" --executor "docker" --docker-image alpine:latest --docker-services postgres:latest
where 11.22.33.44 is the IP of my computer
But when I push my commits, i have an error
Running with gitlab-runner 12.5.0
on Runner
ERROR: Job failed (system failure): Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (executor_docker.go:980:0s)
If I set parameters to expose docker on port 2375 :
settings > General > Expose daemon on tcp://localhost:2375
And in /etc/gitlab-runner/config.toml in the runner container :
[runners.docker]
host = "tcp://11.22.33.44:2375"
I have nearly the same error message :
Running with gitlab-runner 12.5.0 (577f813d)
on Runner
ERROR: Job failed (system failure): Cannot connect to the Docker daemon at tcp://11.22.33.44:2375. Is the docker daemon running? (executor_docker.go:980:1s)
I don't understand from where this comes from.
I have tried some solutions found on internet but till now, nothing worked.
Where can i find some log file to see what happens ? I've looked in the gitlab container /var/log/gitlab log files but I can't find any about details between the 2 containers.
Is there problems between the gitlab hostname, the "localhost" name, the computer IP ? A firewall somewhere ? Is this a problem similar to all those i've seen around ? Does the runner gets the jobs he has to execute but gitlab doesn't hear the answer ?
Most of things i tried so far made the situation getting worst and i would need some hint
My .gitlab-ci.yml (very simple) :
variables:
HELLO: World
test:
script:
- echo $HELLO
My config
Docker Desktop Community edition 2.0.0.3 (Engine 18.09.2)
GitLab Community Edition 12.5.2
Gitlab Runner 12.5.0
Windows 10.0.17763
Thanks
If your goal is to register a docker executor, one simple way is to run a command gitlab-runner.exe register and follow interactive instructions, it will fill up your config.toml
This error also appears when you try to use docker in docker image as you runner image to execute docker commands.
In that case a used runner tag, must have a privileged set to true and in your gitlab-ci file you may define a variable DOCKER_DRIVER: overlay or DOCKER_DRIVER: overlay2
This seems to be solved by
Configuring the runner (/etc/gitlab-runner/config.toml) :
[[runners]]
[runners.docker]
host = "tcp://docker.for.win.localhost"
...
or
[[runners]]
[runners.docker]
host = "tcp://10.0.75.1"
...
I say seems because I still have errors (but not the same)
=> ERROR: Preparation failed: Error response from daemon: The requested URL /v1.25/info was not found on this server
There are some extra steps involved when using the runner from within Docker for Windows.
Let's say we have the host (the IP of the machine running Docker) and the GitLab instance defined as below:
HOST: 11.22.33.44
GITLAB_IP: 55.66.77.88
1. Launch the runner, specify and forward the address to reach the host Docker daemon
docker run -p 2375:2375 -d --name gitlab.runner --env DOCKER_HOST=tcp://11.22.33.44:2375 --restart always -v C:/temp/srv/gitlab-runner/config/:/etc/gitlab.runner -v C:/temp/var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest
2. Register the runner with privileged
docker exec gitlab.runner gitlab-runner register -n --url=http://55.66.77.88:9000/ --registration-token=sEcrEttOkEnfOrgItlAb --description="Shared Docker Runner" --executor=docker --docker-image=docker --docker-privileged=true
3. Expose the port
Open Settings from Docker Desktop for Windows
4. Make the port available to the runner
On Docker for windows, the port 2375 is only accessible via the host loopback (For instance http://127.0.0.1:2375 would work but not http://someRemoteAddress:2375). The GitLab Runner is being run inside its container, so we need to redirect whatever comes from the port 2375 on the GitLab runner instance to the Docker instance.
In an elevated Powershell session do:
netsh interface portproxy add v4tov4 listenport=2375 listenaddress=11.22.33.44 connectport=2375 connectaddress=127.0.0.1
Note that these steps are only needed because the runner is running inside a container. If it were running directly on the host, it would have access to the Docker Daemon.
I'm using Linux containers on Windows and containerize a simple web app to test.
Firstly I create a network with:
docker network create --subnet 192.168.15.0/24 new_network
Afterthat I run
docker container run -d --name web1 --publish 8080:8080 --network new_network test:latest
I inspect and know that IP of that container is 192.168.15.2. But I cannot access to this via 192.168.15.2 or ip:8080. However, when I'm using localhost:8080, it works!
Could pls show me what is the problem and how to fix it.
I think it's normal behavior on Docker Desktop for Windows. Please refer to docker-for-windows and windowscontainers
I have two ubuntu os in my system . I install docker in both ubuntu and create a containers in both the dockers and i need to communicate with the networks ...
Run your container using option --net=host. This way, both containers will have an IP address in your local network.
An example for a container called ubuntu:
docker run -d --name ubuntu --net=host ubuntu
I am building my docker swarm cluster in a sandbox.
I have 1 zookeeper on a machine for discovery, 1 swarm master and 2 swarm nodes.
I try to connect them but when I try to run my docker run commands on the swarm master, it does not distribute the work to the nodes.
Also when I do docker info on the swarm master I can see that the nodes are not connected.
I do not know what I am doing wrong.
Here are the step to reproduce my problem:
I have an empty pwd/data folder and a pwd/config folder with my zoo.cfg:
tickTime=2000
dataDir=/tmp/zookeeper
clientPort=2181
initLimit=5
-
#---- CREATE ZOO ---
docker-machine create --driver virtualbox zoo1
docker-machine start zoo1
eval $(docker-machine env zoo1)
docker pull jplock/zookeeper
docker run -p 2181:2181 -v `pwd`/conf:/opt/zookeeper/conf -v `pwd`/data:/tmp/zookeeper jplock/zookeeper
docker-machine ip zoo1 #############192.168.99.100
-
#--- CREATE CLUSTER ---
docker-machine create --driver virtualbox --swarm --swarm-master machine-smaster
docker-machine create --driver virtualbox --swarm machine-s01
docker-machine create --driver virtualbox --swarm machine-s02
-
eval "$(docker-machine env machine-smaster)"
docker run -p 2375:2375 -d -t swarm manage -H 0.0.0.0:2375 --advertise $(docker-machine ip machine-smaster):2375 zk://192.168.99.100:2181/swarm
docker run swarm list zk://192.168.99.100:2181/swarm
sleep 10
eval "$(docker-machine env machine-s01)"
docker run -d swarm join --advertise $(docker-machine ip machine-s01):2375 zk://192.168.99.100:2181/swarm
docker run swarm list zk://192.168.99.100:2181/swarm
eval "$(docker-machine env machine-s02)"
docker run -d swarm join --advertise $(docker-machine ip machine-s02):2375 zk://192.168.99.100:2181/swarm
docker run swarm list zk://192.168.99.100:2181/swarm
If I run some containers:
eval "$(docker-machine env machine-smaster)"
docker run hello-world
The work is not dispatched to nodes (it is run by the master).
If I run docker info:
eval "$(docker-machine env machine-smaster)"
docker info
I do not see the swarm nodes.
Can you verify that the addresses you're advertising are actually reachable from the manager instance? i.e., does docker -H $(docker-machine ip machine-s01):2375 info return a valid result?
(Note that this subshell won't work inside the manager VM, just on your original client.)
Maybe your problem is that the started Docker Machine instances are listening on :2376 with TLS, but your started Swarm containers are trying to advertise and connect to :2375 without any TLS settings specified?
What do the docker logs for the Swarm containers say?
It looks like you're connecting to the "Swarm master" machine through the Docker API, not the Swarm API. Because of this, Docker will always deploy containers on the host you're connected to, and does not take advantage of Swarm scheduling the containers on the right host.
To connect to the Swarm API, add the --swarm option when running docker-machine env, so in your case:
eval "$(docker-machine env --swarm machine-smaster)"