forked from pavants52/DevOpsDocs
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Docker_Commands.txt
72 lines (56 loc) · 2.99 KB
/
Docker_Commands.txt
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
58
59
60
61
62
63
64
65
66
67
68
69
Reference Link: https://www.tutorialspoint.com/docker/index.htm
docker version
docker info
docker images
docker pull <imageName>
docker run <imageName>
docker run -it <imageName> --> running image on interactive terminal Mode
docker run -d <imageName> --> detached mode of running container
docker ps --> containers which are running
docker ps -a --> all containers started and exited
docker ps -aq --> all container IDs
docker rm <containerID> (or) --> removing one container by ID
docker rm $(docker ps -aq) --> deleting all container by IDs
docker rmi -f <imageID > --> forced removal of one image
docker rmi -f $(docker images -aq) --> remove all the images exist in the system.
All the dangling images with no tags can be viewes through below command
docker images --filter "dangling=true"
docker stop <containerID>
docker start <containerID>
docker kill <containerID>
docker run -d -p 15672:15672 --hostname my-rabbitmq --name messageQ rabbitmq:3-management
docker run -p 8080:8080 -v /var/jenkins_home/:/var/jenkins_home/ -d jenkins
Starting and stoping docker engine service from OS:
service docker stop (To check whether the service is running fire a cmd: docker info)
service docker start (To check whether the service is running fire a cmd: docker info)
DockerFile: --> Set of instruction to build a Image
FROM, MAINTAINER, RUN, ADD,COPY,ENTRYPOINT,CMD,HEALTH...
docker build -t <imgName:TagName> dir (.) ---> It will build a image based on Dockerfile instruction in current directory.
Tag the image to align to Docker Hub repository:
docker tag <currentRepoName> <expectedRepoName> --> eg: docker tag nginx:1.0 manee2k6/nginx:1.0
Below URL helps to configure withDockerRegistry and servers:
https://jenkins.io/doc/pipeline/steps/docker-workflow/
docker login --> Provider username and Password
docker push <repoNameWithTag> --> eg: docker push manee2k6/nginx:1.0
docker inspect <imageID> --> To inspect the configuration of Images created..
docker inspect <repoName:tagName> --> To inspect the configuration of Repository.
Volume mounting uisng -v:
docker run -p 8081:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock --name jenkins -d jenkins-docker
Above docker run command can be executed using Docker-compose file as below:
Ref Link: https://github.com/istresearch/jenkins/blob/master/docker-compose.yml
1. Create a file called as "docker-compose.yml"
2. Copy the code below on the above file.
version: '2'
services:
jenkins:
image: jenkins-docker:latest
container_name: jenkins
user: jenkins
volumes:
- /var/jenkins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
environment:
JENKINS_HOST_HOME: "/var/jenkins_home"
ports:
- "4000:8080"
- "50000:50000"