Repository navigation
Expand file tree
/
Copy pathdocker.txt
More file actions
193 lines (104 loc) · 6.61 KB
/
Copy pathdocker.txt
File metadata and controls
193 lines (104 loc) · 6.61 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
container > is a instance of image.
image > download from docker hub.
/var/lib/docker/
builder buildkit containers image network overlay2 plugins runtimes swarm tmp trust volumes
# starting container ---------------------------------------
docker image pull hello-world
docker pull ubuntu:14.04
docker image ls
docker container run ubuntu/nginx
docker container run ubuntu sleep 30
docker container ls
docker container ls -a
docker ps
docker container logs <con-id>
# container in background(start|stop|detach) ----------------
docker container run -d nginx
docker container stop <con-id>
docker container start <con-id>
docker container restart <con-id>
docker container run -d --name nginx-node-one nginx
docker container run -d --name nginx-node-two nginx
docker container run -it nginx /bin/bash
docker exec -it <con-id> /bin/bash
ctrl p+q || leave bash without stopping container
docker container rm <con-id>
docker container prune
docker container ls -aq || print all containers id
docker container rm $(docker container ls -aq)
docker container inspect <con-id>
# container-log-starts-top --------------------------------
ps -aux | grep nginx || both host-machine and container has same process id
docker container top 3be2f959e6a
docker container top 1c973430b1
docker container logs 3be2f959e6a
docker container stats
# container port-mapping rename ---------------------------
docker container rename <exiting-name> <new-name>
docker container run -d -p 8080:80 --name nginx-node-port-mapped nginx
docker container run -d -p 80:80 nginx
docker update --restart unless-stopped <con-id> || used to boot container after reboot container-machine
docker container run -d --restart unless-stopped -p 80:80 --name mynginx nginx
# container attach -kill-pause-port ------------------------
docker container attach <con-id> || display input..output..error stream message
docker container kill <con-id> || stop attempts to trigger a graceful shutdown by sending the standard signal terminal SIGTERM, whereas kill just kills the proces by default.
docker container puase| unpause <con-id>
docker container port <con-id>
# container create.. diff.. copy file to container -----------
-diff > its inspect changes to files or directories on a containers filesystem.
docker container create ubuntu sleep 60
docker container run <con-id>
docker container diff <con-id> || open another terminal [watch 'docker conatiner diff [con-id]'.. see what chages is occured]
docker container cp /host-machine-files/ <con-id>:/files-location
# container export-import ----------------------------------
docker container run -it ubuntu /bin/bash
apt-get -y update
apt-get install -y tree git
docker container export 43fbs456 > my_ubuntu_tree_git.tar
docker container export 43fbs456 -o my_ubuntu_tree_git.tar
docker image import my_ubuntu_tree_git.tar my_ubutnu_img
docker image ls
docker container run -it my_ubutnu_img /bin/bash
git --version
tree
docker container ls
# create docker-image from running container ----------------
docker container run -it ubuntu bash
cd /tmp -> mkdir {1..100} ->
docker container commit --author "Faiz" -m "MyUbuntu" <b7caa43a2d15> <my_ubuntu_img>
docker image ls
docker container run -it my_ubuntu_img bash
docker container ls
# docker push image to hub and add tag ------------------------
docker image ls
docker login
docker image tag my_ubuntu_img faizxn/my_ubuntu_custom_file
docker push faizxn/my_ubuntu_custom_file
docker image pull nginx
docker image ls
docker image tag nginx faizxn/nginx
docker push faizxn/nginx
# docker history and filtering-inspect --------------------------
docker image history nginx
docker image ls --format '{{'.ID'}}, {{.Tag}}'
docker image ls --format '{{'.ID'}}, {{.Tag}} - {{.Repository}}'
ba4bfdc0c69f, latest - faizxn/my_ubuntu_custom_file
ba4bfdc0c69f, latest - my_ubuntu_img
74435f89ab78, latest - ubuntu
2622e6cca7eb, latest - nginx
# docker image save..load ----------------------------------------
export > is used to export the container’s file system into a tar file. it doesn’t export any volumes associated with it.
save > is used to save one or more images into a tar file with layer.
<!---- save and export are both used for sharing tar files. but, save is used for images and can save multiple images into a tar file with all the layers and history -->
docker image save nginx > nginx.tar
ls
docker image load < nginx.tar
docker image ls
# docker arhitecture layer and dockerfile -------------------------
# docker network ---------------------------------------------------
- by default one bridge network cant communicate with another bridge network. it needs to map ports or dns to communicate each other.
bridge-network : we can multiple bridge network and attach it to containers
host-network : this only allow for once at container. everything is isolated except network. it behave exact like host machine ip address.
none-network : this is used if we dont want any ip address to containers.
network-dns : manually created bridge network dns is enabled by default.
docker network connect/disconnect <network-name> <container-id> || to add addtional container network.. we can multiple bridge networks to containers.