forked from khalednoh/instrctions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-commands
57 lines (40 loc) · 2.13 KB
/
docker-commands
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
e) in jenkins UI portal:
-----------------------
open jenkins dashboard > manage jenkins > manage plugins > install the following plugins
"Docker", "Docker API" "Docker Pipeline" "" , "Docker build steps", "CloudBees Docker Build and Publish plugin" and "Docker Commons Plugin"
b)In jenkins machine, run the below Install Docker engine <https://docs.docker.com/engine/install/ubuntu/>:
------------------------------------------------------------------------------------------------------------
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo docker run hello-world
c) In jenkins machine, Manage Docker as a non-root user:
--------------------------------------------------------
sudo groupadd docker // Add the docker group if it doesn't already exist
sudo gpasswd -a jenkins docker // Add the connected user jenkins to the docker group.
newgrp docker
docker run hello-world // to check if you can run docker without sudo
systemctl restart docker // restart the docker daemon to get things working
sudo chmod 666 /var/run/docker.sock // that is the key
d) supporting commands to manage jenkins user:
----------------------------------------------
getent passwd // To get a list of all Linux user
less /etc/passwd // Get a List of All Users using the /etc/passwd File
getent passwd | grep jenkins // list details of specific user ex: jenkins
sudo passwd jenkins // set the password for user jenkins
e) stop asking the password for sudo:
-------------------------------------
sudo visudo // run this command
jenkins ALL=(ALL) NOPASSWD: ALL // at the end of the file add this line then click ctrl+x