Skip to content

Commit 7e7f341

Browse files
authored
Merge pull request #33 from aamir296/master
Update readme.md for docker commands
2 parents a828ad1 + ad44023 commit 7e7f341

1 file changed

Lines changed: 191 additions & 7 deletions

File tree

docker/readme.md

Lines changed: 191 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,107 +41,291 @@
4141

4242
# Commands
4343

44-
```
44+
```bash
45+
# Check the version of Docker installed
4546
docker --version
47+
48+
# Run a Docker container with a Python hello world application
4649
docker run -p 5000:5000 in28min/hello-world-python:0.0.1.RELEASE
50+
51+
# Run a Docker container with a Java hello world application
4752
docker run -p 5000:5000 in28min/hello-world-java:0.0.1.RELEASE
53+
54+
# Run a Docker container with a Node.js hello world application
4855
docker run -p 5000:5000 in28min/hello-world-nodejs:0.0.1.RELEASE
56+
57+
# Run a Docker container with a Node.js hello world application in detached mode
4958
docker run -d -p 5000:5000 in28min/hello-world-nodejs:0.0.1.RELEASE
59+
60+
# Run a Docker container with a Python hello world application in detached mode
5061
docker run -d -p 5001:5000 in28min/hello-world-python:0.0.1.RELEASE
62+
63+
# View the logs of a Docker container
5164
docker logs 04e52ff9270f5810eefe1f77222852dc1461c22440d4ecd6228b5c38f09d838e
65+
66+
# View the logs of a Docker container with a given container ID or name
5267
docker logs c2ba
68+
69+
# List Docker images
5370
docker images
71+
72+
# List running containers
5473
docker container ls
74+
75+
# List all containers, including stopped ones
5576
docker container ls -a
77+
78+
# Stop a running container with a given container ID
5679
docker container stop f708b7ee1a8b
80+
81+
# Run a Docker container with a REST API in detached mode
5782
docker run -d -p 5001:8080 in28min/hello-world-rest-api:0.0.1.RELEASE
83+
84+
# Pull a Docker image from a registry
5885
docker pull mysql
86+
87+
# Search for Docker images in a registry
5988
docker search mysql
89+
90+
# Show the history of a Docker image
6091
docker image history in28min/hello-world-java:0.0.1.RELEASE
92+
93+
# Show the history of a Docker image with a given image ID
6194
docker image history 100229ba687e
95+
96+
# Inspect a Docker image
6297
docker image inspect 100229ba687e
98+
99+
# Remove a Docker image
63100
docker image remove mysql
101+
102+
# Remove a Docker image with a given image name and tag
64103
docker image remove in28min/hello-world-java:0.0.1.RELEASE
104+
105+
# Remove a Docker container with a given container ID or name
65106
docker container rm 3e657ae9bd16
107+
108+
# List all containers, including stopped ones
66109
docker container ls -a
110+
111+
# Pause a running container with a given container ID or name
67112
docker container pause 832
113+
114+
# Unpause a paused container with a given container ID or name
68115
docker container unpause 832
116+
117+
# Stop a running container with a given container ID or name
69118
docker container stop 832
119+
120+
# Inspect a Docker container with a given container ID or name
70121
docker container inspect ff521fa58db3
122+
123+
# Remove all stopped containers
71124
docker container prune
125+
126+
# Show Docker system information
72127
docker system
128+
129+
# Show Docker disk usage
73130
docker system df
131+
132+
# Show detailed Docker system information
74133
docker system info
134+
135+
# Remove all unused Docker resources
75136
docker system prune -a
137+
138+
# Display the top resource-consuming processes of a Docker container with a given container ID or name
76139
docker top 9009722eac4d
140+
141+
# Show live resource usage statistics of a Docker container with a given container ID or name
77142
docker stats 9009722eac4d
143+
144+
# Run a Docker container with a Java hello world application, limited to 512MB memory
78145
docker container run -p 5000:5000 -d -m 512m in28min/hello-world-java:0.0.1.RELEASE
79-
docker container run -p 5000:5000 -d -m 512m --cpu-quota=50000 in28min/hello-world-java:0.0.1.RELEASE
146+
147+
# Run a Docker container with a Java hello world application, limited to 512MB memory and CPU quota of 50%
148+
docker container run -p 5000:5000 -d -m 512m --cpu-quota=50000 in28min/hello-world-java:0.0.1.RELEASE
149+
150+
# Show Docker system events
80151
docker system events
81152

153+
154+
155+
156+
# Show live resource usage statistics of a Docker container with a given container ID or name
82157
docker container stats 4faca1ea914e3e4587d1d790948ec6cb8fa34f26e900c12632fd64d4722fd59a
158+
159+
# Show live resource usage statistics of a Docker container with a given container ID or name
83160
docker stats 42f170966ce613d2a16d7404495af7b3295e01aeb9142e1fa1762bbdc581f502
84161

85-
cd /in28Minutes/git/devops-master-class/projects/hello-world/hello-world-python
86-
docker build -t in28min/hello-world-python:0.0.2.RELEASE .
162+
163+
164+
165+
# Change directory to the Python hello world project
166+
cd /in28Minutes/git/devops-master-class/projects/hello-world/hello-world-python
167+
168+
# Build a Docker image with a given tag
169+
docker build -t in28min/hello-world-python:0.0.2.RELEASE .
170+
171+
# Run a Docker container with a Python hello world application, mapped to port 5000
87172
docker run -p 5000:5000 -d in28min/hello-world-python:0.0.2.RELEASE
173+
174+
# Show the history of a Docker image with a given image ID
88175
docker history e66dc383f7a0
176+
177+
# Push a Docker image to a registry
89178
docker push in28min/hello-world-python:0.0.2.RELEASE
90179

180+
181+
182+
183+
# Change directory to the Node.js hello world project
91184
cd ../hello-world-nodejs/
92-
docker build -t in28min/hello-world-nodejs:0.0.2.RELEASE .
185+
186+
# Build a Docker image with a given tag
187+
docker build -t in28min/hello-world-nodejs:0.0.2.RELEASE .
188+
189+
# Run a Docker container with a Node.js hello world application, mapped to port 5000
93190
docker container run -d -p 5000:5000 in28min/hello-world-nodejs:0.0.2.RELEASE
191+
192+
# Push a Docker image to a registry
94193
docker push in28min/hello-world-nodejs:0.0.2.RELEASE
95194

195+
# Change directory to the Java hello world project
96196
cd ../hello-world-java/
97-
docker build -t in28min/hello-world-java:0.0.2.RELEASE .
197+
198+
# Build a Docker image with a given tag
199+
docker build -t in28min/hello-world-java:0.0.2.RELEASE .
200+
201+
# Run a Docker container with a Java hello world application, mapped to port 5000
98202
docker run -d -p 5000:5000 in28min/hello-world-java:0.0.2.RELEASE
203+
204+
# Push a Docker image to a registry
99205
docker push in28min/hello-world-java:0.0.2.RELEASE
100206

207+
208+
209+
210+
# Run a Docker container with a Node.js hello world application, mapped to port 5001 and ping google.com
101211
docker run -d -p 5001:5000 in28min/hello-world-nodejs:0.0.3.RELEASE ping google.com
102212

103213

214+
215+
216+
# Run a Docker container with a currency exchange service
104217
docker run -d -p 8000:8000 --name=currency-exchange in28min/currency-exchange:0.0.1-RELEASE
218+
219+
# Run a Docker container with a currency conversion service
105220
docker run -d -p 8100:8100 --name=currency-conversion in28min/currency-conversion:0.0.1-RELEASE
106221

222+
223+
224+
225+
# List Docker networks
107226
docker network ls
227+
228+
# Inspect a Docker network with a given network name
108229
docker network inspect bridge
109230

231+
232+
233+
234+
# Run a Docker container with a currency conversion service, linked to the currency exchange service and environment variable set
110235
docker run -d -p 8100:8100 --env CURRENCY_EXCHANGE_SERVICE_HOST=http://currency-exchange --name=currency-conversion --link currency-exchange in28min/currency-conversion:0.0.1-RELEASE
111236

237+
238+
239+
240+
# Create a Docker network with a given network name
112241
docker network create currency-network
242+
243+
# Stop a running container with a given container ID or name
113244
docker container stop currency-exchange
245+
246+
# Stop a running container with a given container ID or name
114247
docker container stop currency-conversion
248+
249+
# Run a Docker container with a currency exchange service, connected to the currency-network
115250
docker run -d -p 8000:8000 --name=currency-exchange --network=currency-network in28min/currency-exchange:0.0.1-RELEASE
251+
252+
# Run a Docker container with a currency conversion service, connected to the currency-network and environment variable set
116253
docker run -d -p 8100:8100 --env CURRENCY_EXCHANGE_SERVICE_HOST=http://currency-exchange --name=currency-conversion --network=currency-network in28min/currency-conversion:0.0.1-RELEASE
117254

255+
256+
257+
258+
# Check the version of Docker Compose installed
118259
docker-compose --version
260+
261+
# Change directory to the microservices folder
119262
cd ../../microservices/
263+
264+
# Start the services defined in the Docker Compose file
120265
docker-compose up
266+
267+
# Start the services defined in the Docker Compose file in detached mode
121268
docker-compose up -d
269+
270+
# List running containers
122271
docker container ls
272+
273+
# List Docker networks
123274
docker network ls
275+
276+
# Inspect a Docker network with a given network name
124277
docker network inspect microservices_currency-compose-network
278+
279+
# Stop the services defined in the Docker Compose file
125280
docker-compose down
281+
282+
# List all containers, including stopped ones
126283
docker container ls -a
284+
285+
# Remove all unused Docker resources
127286
docker system prune -a
287+
288+
# Validate the Docker Compose file
128289
docker-compose config
290+
291+
# List Docker images used by the services defined in the Docker Compose file
129292
docker-compose images
293+
294+
# List the running services defined in the Docker Compose file
130295
docker-compose ps
296+
297+
# Display the top resource-consuming processes of the services defined in the Docker Compose file
131298
docker-compose top
132299

300+
133301
```
134302

135303

136-
```
304+
```bash
305+
# Build a Docker image for a Java hello world application with a given tag
137306
docker build -t in28min/hello-world-java:0.0.1.RELEASE .
307+
308+
# Push the Docker image with the specified tag to a registry
138309
docker push in28min/hello-world-java:0.0.1.RELEASE
139310

311+
312+
313+
314+
# Build a Docker image for a Python hello world application with a given tag
140315
docker build -t in28min/hello-world-python:0.0.1.RELEASE .
316+
317+
# Push the Docker image with the specified tag to a registry
141318
docker push in28min/hello-world-python:0.0.1.RELEASE
142319

320+
321+
322+
323+
# Build a Docker image for a Node.js hello world application with a given tag
143324
docker build -t in28min/hello-world-nodejs:0.0.1.RELEASE .
325+
326+
# Push the Docker image with the specified tag to a registry
144327
docker push in28min/hello-world-nodejs:0.0.1.RELEASE
328+
145329
```
146330

147331
### Host Networking in Docker for Mac and Windows

0 commit comments

Comments
 (0)