Docker cleanup Short cuts and with AWK

Docker cleanup Short cuts with AWK


New:

[root@ip-172--37 etc]# docker container prune
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
415ec042e613aa3b767302440776042f7f05bcaac323349b893539b045643c00
34bfc4c420c2b2546e4f09980536040e134c472a0369082531a924293f569e07
12691c6aed14d098255e234498d8c757d675bc8d45d6341b261ab882ab9e1422
f7296839421ac5d2fd8c9f43e68f3c8139d17bcc49d530da4cc2904d570b3b75

Total reclaimed space: 36.57MB

[root@ip-17-32-37 etc]#

[root@ip-172-31-32-37 etc]# docker images prune
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

[root@ip-172-31-32-37 etc]# docker images prune

(for removing dangling and ununsed images).

[root@ip-172-31-32-37 etc]# docker image prune -a
WARNING! This will remove all images without at least one container associated to them.
Are you sure you want to continue? [y/N] y
Deleted Images:
untagged: mattrayner/lamp:latest-1604
untagged: mattrayner/lamp@sha256:f354e15c4e3b4cc0808aafa46ceb30a7a61eadabcfcdd39087feaf3328e4305d

Total reclaimed space: 0B

[root@ip-172-31-32-37 etc]# docker volume prune
WARNING! This will remove all local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Deleted Volumes:
b569eae3b83eb3eb3aca08a94f553f2998badd559378e24933405fd06a808f16
0cc6019d1af28a64462199e0cfc9e5c937b819a3bf72e82a41005cb09ecc57f4
39ac8810b6d9dba5a68765f839bc94d6f2cdd620fe152e4c61fb49b2f7db493c
bef1ba8ec1425520343fc421e60179c3afa8a3eaaa69d56b9401dfd2712d2e78
1c13a3b07f2466bbbe5ed3cbc00f3d7e7addd8ca974a3fa10c14607143c62e6f
ee95981e0eff756d6007783b1a363aa663d7df42d219c76f408be55de9e9db8d

Total reclaimed space: 139.2MB
[root@ip-172-31-32-37 etc]#


root@docker:~# docker images | awk '{print $1 ":" $2}' | xargs docker rmi -f
Untagged: bibinwilson/jenkins-slave:latest
Untagged: bibinwilson/jenkins-slave@sha256:dda6abf1cda7aa9eb7bef44cb3f209c8cdf230dd988fd6d72d07ce829c26a36e
Deleted: sha256:a6c4332f1b747938c4593edcd243d529fde72315281aa5cfc029c775c0ff9f1d
Error response from daemon: invalid reference format: repository name must be lowercase
root@docker:~# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
root@docker:~# 
root@docker:~# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
7aec23b3448b        a6c4332f1b74        "/bin/bash"         22 hours ago        Exited (130) 22 hours ago                       happy_panini
1f3ba05d2bbd        a6c4332f1b74        "/bin/bash"         22 hours ago        Exited (0) 22 hours ago                         cranky_brahmagupta
fbb8f3c9d809        a6c4332f1b74        "/bin/bash"         22 hours ago        Exited (0) 22 hours ago                         hardcore_keller
431297d54259        14f60031763d        "/bin/bash"         26 hours ago        Exited (0) 26 hours ago                         trusting_bardeen
root@docker:~# 
root@docker:~# docker ps -a | awk 'NR>1'|awk '{print $1}' |xargs docker rm
7aec23b3448b
1f3ba05d2bbd
fbb8f3c9d809
431297d54259
root@docker:~# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
root@docker:~# 

Another method:


# docker ps -a | awk 'NR>1' |awk '{print $1}' > rmcntid.out


# for i in `cat rmcntid.out` ; do docker rm $i ; done

how to configure Jenkins' Slave Nodes

Please follow the screen shots

Go to Configure Jenkins







[root@localhost Downloads]# scp  -i jenkinsnew.pem  slave.jar ubuntu@34.230.90.99:/home/ubuntu/
slave.jar                                                                                                          100%  713KB 713.2KB/s   00:00    
[root@localhost Downloads]# 



java -jar slave.jar -jnlpUrl http://ec2-54-210-147-105.compute-1.amazonaws.com:8080/computer/slave1/slave-agent.jnlp -secret 2120971706c29441e2b7340883b76ac6392aae123899dff360bf6c6777d0517a



root@docker:/var/lib/jenkins# java -jar slave.jar -jnlpUrl http://ec2-54-210-147-105.compute-1.amazonaws.com:8080/computer/slave1/slave-agent.jnlp -secret 2120971706c29441e2b7340883b76ac6392aae123899dff360bf6c6777d0517a
Jul 28, 2017 4:47:54 PM hudson.remoting.jnlp.Main createEngine
INFO: Setting up slave: slave1
Jul 28, 2017 4:47:54 PM hudson.remoting.jnlp.Main$CuiListener 
INFO: Jenkins agent is running in headless mode.
Jul 28, 2017 4:47:54 PM hudson.remoting.Engine startEngine
WARNING: No Working Directory. Using the legacy JAR Cache location: /root/.jenkins/cache/jars
Jul 28, 2017 4:47:54 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among [http://ec2-54-210-147-105.compute-1.amazonaws.com:8080/]
Jul 28, 2017 4:47:54 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
INFO: Remoting server accepts the following protocols: [JNLP4-connect, CLI2-connect, JNLP-connect, Ping, CLI-connect, JNLP2-connect]
Jul 28, 2017 4:47:54 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Agent discovery successful
  Agent address: ec2-54-210-147-105.compute-1.amazonaws.com
  Agent port:    39544
  Identity:      52:d2:fa:44:9e:46:02:30:24:5d:7c:ab:16:3e:ab:0a
Jul 28, 2017 4:47:54 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Handshaking
Jul 28, 2017 4:47:54 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connecting to ec2-54-210-147-105.compute-1.amazonaws.com:39544
Jul 28, 2017 4:47:54 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Trying protocol: JNLP4-connect
Jul 28, 2017 4:47:54 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Remote identity confirmed: 52:d2:fa:44:9e:46:02:30:24:5d:7c:ab:16:3e:ab:0a
Jul 28, 2017 4:47:55 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connected

Once it is connected you will see the Node - slave as Connected and in Green.
Congrats!!! you can run your jobs on the Slave/clients now.
I have created a sample project with just a Shell script on the slave node and I am able to Build my project on the Slave now...

I did not use any complex build, since this demo is to show only how to configure Jenkins Agents. Later you can play around with complex configuration once the connectivity is met.

I have tried to use :"Docker SSH", "SSH clients", Cloud as "Docker", AWS cloud config but nothing worked as expected. But this one is pretty simple and easy.











Installing Ingress Controller - Kubernetes

Installing the Ingress Controller Prerequisites Make sure you have access to the Ingress controller image: For NGINX Ingress controll...