Docker: Portainer Server vs Agent Only Deployment - docker

I just installed Portainer CE by following Docker on Windows WSL / Docker Desktop section as shown below:
Open a terminal and run the following command:
create portainer_data
And then:
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always
-v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
Then login to the system via http://localhost:9000 without any problem (also define admin pass).
On the other hand, there is an additional section just below the second command as shown below:
Portainer Agent Only Deployment
Run the following command to deploy the Agent in your Docker host.
docker run -d -p 9001:9001 --name portainer_agent --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes portainer/agent
Is there any need to use that command and what is the benefit of Portainer Agent exactly? What is Portainer Server vs Agent Only Deployment?

Related

Can we run docker inside a docker container which is running in a virtual-box of Ubuntu 18.04?

I want to run docker inside another docker container. My main container is running in a virtualbox of OS Ubuntu 18.04 which is there on my Windows 10. On trying to run it, it is showing me as:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
How can I resolve this issue?
Yes, you can do this. Check for dind (docker in docker) on docker webpage how to achieve it: https://hub.docker.com/_/docker
Your error indicates that either dockerd in the top level container is not running or you didn't mount docker.sock on the dependent container to communicate with dockerd running on your top-level container.
I am running electric-flow in a docker container in my Ubuntu virtual-box using this docker command: docker run --name efserver --hostname=efserver -d -p 8080:8080 -p 9990:9990 -p 7800:7800 -p 7070:80 -p 443:443 -p 8443:8443 -p 8200:8200 -i -t ecdocker/eflow-ce. Inside this docker container, I want to install and run docker so that my CI/CD pipeline in electric-flow can access and use docker commands.
From your above description, ecdocker/eflow-ce is your CI/CD solution container, and you just want to use docker command in this container, then you did not need dind solution. You can just access to a container's host docker server.
Something like follows:
docker run --privileged --name efserver --hostname=efserver -d -p 8080:8080 -p 9990:9990 -p 7800:7800 -p 7070:80 -p 443:443 -p 8443:8443 -p 8200:8200 -v $(which docker):/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -i -t ecdocker/eflow-ce
Compared to your old command:
Add --privileged
Add -v $(which docker):/usr/bin/docker, then you can use docker client in container.
Add -v /var/run/docker.sock:/var/run/docker.sock, then you can access host's docker daemon using client in container.

Invalid volume specification trying to run portainer container

I'm trying to deploy portainer to my local docker. I'm running the Docker CE 18.0.6.0 version on Windows 10. I tried to follow the steps from these two pages:
Portainer-Deployment
Tutorial: Portainer for local Docker environments on Windows
10!
But all the times I have tried to run the following command:
docker run -d -p 9000:9000 --name portainer --restart always -v portainer_data:/data portainer/portainer -H tcp://10.0.75.1:2375
Docker responds always with the same message:
Error response from daemon: invalid volume specification:
'portainer_data:/data'
I created the volume using this command:
docker volume create portainer_data
Any idea what could be?
The path syntax you used only works for Linux containers since Linux environments only have a single root to their filesystem tree. To run portainer container in a native Windows container, the syntax is:
docker run -d -p 9000:9000 --name portainer --restart always -v \\.\pipe\docker_engine:\\.\pipe\docker_engine -v C:\ProgramData\Portainer:C:\data portainer/portainer
This comes from the deployment documentation.

Link containers to a running container

I want to know if I can link Docker containers to a running container. I am running this command on a server:
docker run -d -u jenkins --name appdev-jenkins --network=host --memory="8g" -p 80:8080 -p 443:443 -p 50000:50000 -v "/opt/jenkins":/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkinsci/blueocean
I want to be able to link another Jenkins instance as an agent to the original Jenkins instance. Is this possible?
Have you tried the following?
docker run -d --link appdev-jenkins --name second-jenkins [other params]

Need to create listener for docker plugin on Jenkins on port 2375

I am trying to use the following docker command to create a jenkins container server along with enabling the docker api for the docker plugin.
docker run --name myjenkins -p 8080:8080 -d -p 50000:50000 -v /var/jenkins_home -H tcp://127.0.0.1:2375 jenkins
Unfortunately i am getting the below error message which indicates the -H flag isn't allowed on docker run
`unknown shorthand flag: 'H' in -H
See 'docker run --help'.`
Any ideas on what to do in order to create this listener?

Docker port rewrite

I used docker for wordpress like this:
Create volume containers:
$ docker create -v /home/juanda/project/bbdd:/var/lib/mysql --name bbdd ubuntu /bin/true
$ docker create -v /home/juanda/project/web:/var/www/html --name web ubuntu /bin/true
Mysql container:
$ docker run --volumes-from bbdd --name mysql -e MYSQL_ROOT_PASSWORD="xxxx" -d mysql
Apache, php and wordpress container:
$ docker run --volumes-from web --name apache --link mysql:mysql -d -p 5555:80 wordpress
I installed and ran everything ok. If I remove apache container (stop and rm) and I launch it awain in another port (8080 instead of 5555), it rewrites url in navigator to 5555 and I get a connection error. Any idea?

Resources