-
Notifications
You must be signed in to change notification settings - Fork 0
/
Docker Commands.txt
151 lines (77 loc) · 2.84 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
1) To build an image out of a docker file:
docker build -f dockerfile . -t prasantikadiyala/mysampleimage
2) to pull an image:
docker pull <imagename>:tag --> docker pull nginx:latest ; nginx:stable-perl
3) to push the image to a repository
docker push <username>/<reponame>:<tag>
4) To list all the images:
docker images
or
docker image ls
5) To create a container:
docker container create --name mycont --publish 8080:80 nginx
or
docker container create --name mycont -p 8080:80 nginx
6) To start a container:
docker container start mycont
or
docker start mycont
7) Command to create and start a container:
docker run --name mycont -p 8080:80 -d nginx
8) To stop a container:
docker container stop mycont
or
docker stop mycont
9) To kill a container: (Kill will stop the container abruptly and doesnt
give time for the processes to clean up)
docker kill <cont name>
10) To list all the running containers:
docker ps
11) To list all the containers:
docker ps -a
12) To copy a folder from container to host or viceversa:
docker cp <cont name>:<folder> <folder on host>
docker cp <folder on host> <cont name>:<folder>
13) To see the file system differences since the start of hte container:
docker diff <cont name>
14) To commit the current state of a container to a new image:
docker commit <cont name> <image name>
15) To see the instructions executed as part of the image creation:
docker history <image name>
16) To inspect a resource in docker:
docker inspect <cont name / imagename / network name>
17) To print the stats of a container:
docker stats <cont name>
18) To pause a container:
docker pause <cont name>
to test it issue docker exec command
19) To unpause a container:
docker unpause <cont name>
20) To remove a container:
docker container rm mycont
or
docker rm mycont
21) To remove all the stopped containers:
docker prune
22) To export the filesystem into a tar file:
docker export <cont name> -o testcontainer.tar
23) To view the logs from stdio of hte container
docker logs <cont name>
docker container logs --follow mycont
docker container logs --tail 1 mycont
docker container logs --tail 10 --timestamps mycont
docker container logs --since 15m --timestamps mycont
docker container logs --since 2020-04-06T11:08:15 –timestamps mycont
24) to remove an image
docker image rm <image name>
or
docker rmi <image name>
25) to see all the events happening on a node
docker events --since '2020-12-15'
docker events --since '2021-03-08' --filter container=mycont --filter event=start
26) to list all the port mappings:
docker container port <name >
or
docker port <name>
27) To increase the storage on container:
dockerd --storage-opt dm.basesize=20G