|
41 | 41 |
|
42 | 42 | # Commands |
43 | 43 |
|
44 | | -``` |
| 44 | +```bash |
| 45 | +# Check the version of Docker installed |
45 | 46 | docker --version |
| 47 | + |
| 48 | +# Run a Docker container with a Python hello world application |
46 | 49 | 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 |
47 | 52 | 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 |
48 | 55 | 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 |
49 | 58 | 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 |
50 | 61 | docker run -d -p 5001:5000 in28min/hello-world-python:0.0.1.RELEASE |
| 62 | + |
| 63 | +# View the logs of a Docker container |
51 | 64 | docker logs 04e52ff9270f5810eefe1f77222852dc1461c22440d4ecd6228b5c38f09d838e |
| 65 | + |
| 66 | +# View the logs of a Docker container with a given container ID or name |
52 | 67 | docker logs c2ba |
| 68 | + |
| 69 | +# List Docker images |
53 | 70 | docker images |
| 71 | + |
| 72 | +# List running containers |
54 | 73 | docker container ls |
| 74 | + |
| 75 | +# List all containers, including stopped ones |
55 | 76 | docker container ls -a |
| 77 | + |
| 78 | +# Stop a running container with a given container ID |
56 | 79 | docker container stop f708b7ee1a8b |
| 80 | + |
| 81 | +# Run a Docker container with a REST API in detached mode |
57 | 82 | docker run -d -p 5001:8080 in28min/hello-world-rest-api:0.0.1.RELEASE |
| 83 | + |
| 84 | +# Pull a Docker image from a registry |
58 | 85 | docker pull mysql |
| 86 | + |
| 87 | +# Search for Docker images in a registry |
59 | 88 | docker search mysql |
| 89 | + |
| 90 | +# Show the history of a Docker image |
60 | 91 | 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 |
61 | 94 | docker image history 100229ba687e |
| 95 | + |
| 96 | +# Inspect a Docker image |
62 | 97 | docker image inspect 100229ba687e |
| 98 | + |
| 99 | +# Remove a Docker image |
63 | 100 | docker image remove mysql |
| 101 | + |
| 102 | +# Remove a Docker image with a given image name and tag |
64 | 103 | docker image remove in28min/hello-world-java:0.0.1.RELEASE |
| 104 | + |
| 105 | +# Remove a Docker container with a given container ID or name |
65 | 106 | docker container rm 3e657ae9bd16 |
| 107 | + |
| 108 | +# List all containers, including stopped ones |
66 | 109 | docker container ls -a |
| 110 | + |
| 111 | +# Pause a running container with a given container ID or name |
67 | 112 | docker container pause 832 |
| 113 | + |
| 114 | +# Unpause a paused container with a given container ID or name |
68 | 115 | docker container unpause 832 |
| 116 | + |
| 117 | +# Stop a running container with a given container ID or name |
69 | 118 | docker container stop 832 |
| 119 | + |
| 120 | +# Inspect a Docker container with a given container ID or name |
70 | 121 | docker container inspect ff521fa58db3 |
| 122 | + |
| 123 | +# Remove all stopped containers |
71 | 124 | docker container prune |
| 125 | + |
| 126 | +# Show Docker system information |
72 | 127 | docker system |
| 128 | + |
| 129 | +# Show Docker disk usage |
73 | 130 | docker system df |
| 131 | + |
| 132 | +# Show detailed Docker system information |
74 | 133 | docker system info |
| 134 | + |
| 135 | +# Remove all unused Docker resources |
75 | 136 | docker system prune -a |
| 137 | + |
| 138 | +# Display the top resource-consuming processes of a Docker container with a given container ID or name |
76 | 139 | docker top 9009722eac4d |
| 140 | + |
| 141 | +# Show live resource usage statistics of a Docker container with a given container ID or name |
77 | 142 | docker stats 9009722eac4d |
| 143 | + |
| 144 | +# Run a Docker container with a Java hello world application, limited to 512MB memory |
78 | 145 | 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 |
80 | 151 | docker system events |
81 | 152 |
|
| 153 | + |
| 154 | + |
| 155 | + |
| 156 | +# Show live resource usage statistics of a Docker container with a given container ID or name |
82 | 157 | docker container stats 4faca1ea914e3e4587d1d790948ec6cb8fa34f26e900c12632fd64d4722fd59a |
| 158 | + |
| 159 | +# Show live resource usage statistics of a Docker container with a given container ID or name |
83 | 160 | docker stats 42f170966ce613d2a16d7404495af7b3295e01aeb9142e1fa1762bbdc581f502 |
84 | 161 |
|
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 |
87 | 172 | 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 |
88 | 175 | docker history e66dc383f7a0 |
| 176 | + |
| 177 | +# Push a Docker image to a registry |
89 | 178 | docker push in28min/hello-world-python:0.0.2.RELEASE |
90 | 179 |
|
| 180 | + |
| 181 | + |
| 182 | + |
| 183 | +# Change directory to the Node.js hello world project |
91 | 184 | 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 |
93 | 190 | docker container run -d -p 5000:5000 in28min/hello-world-nodejs:0.0.2.RELEASE |
| 191 | + |
| 192 | +# Push a Docker image to a registry |
94 | 193 | docker push in28min/hello-world-nodejs:0.0.2.RELEASE |
95 | 194 |
|
| 195 | +# Change directory to the Java hello world project |
96 | 196 | 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 |
98 | 202 | docker run -d -p 5000:5000 in28min/hello-world-java:0.0.2.RELEASE |
| 203 | + |
| 204 | +# Push a Docker image to a registry |
99 | 205 | docker push in28min/hello-world-java:0.0.2.RELEASE |
100 | 206 |
|
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | +# Run a Docker container with a Node.js hello world application, mapped to port 5001 and ping google.com |
101 | 211 | docker run -d -p 5001:5000 in28min/hello-world-nodejs:0.0.3.RELEASE ping google.com |
102 | 212 |
|
103 | 213 |
|
| 214 | + |
| 215 | + |
| 216 | +# Run a Docker container with a currency exchange service |
104 | 217 | 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 |
105 | 220 | docker run -d -p 8100:8100 --name=currency-conversion in28min/currency-conversion:0.0.1-RELEASE |
106 | 221 |
|
| 222 | + |
| 223 | + |
| 224 | + |
| 225 | +# List Docker networks |
107 | 226 | docker network ls |
| 227 | + |
| 228 | +# Inspect a Docker network with a given network name |
108 | 229 | docker network inspect bridge |
109 | 230 |
|
| 231 | + |
| 232 | + |
| 233 | + |
| 234 | +# Run a Docker container with a currency conversion service, linked to the currency exchange service and environment variable set |
110 | 235 | 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 |
111 | 236 |
|
| 237 | + |
| 238 | + |
| 239 | + |
| 240 | +# Create a Docker network with a given network name |
112 | 241 | docker network create currency-network |
| 242 | + |
| 243 | +# Stop a running container with a given container ID or name |
113 | 244 | docker container stop currency-exchange |
| 245 | + |
| 246 | +# Stop a running container with a given container ID or name |
114 | 247 | docker container stop currency-conversion |
| 248 | + |
| 249 | +# Run a Docker container with a currency exchange service, connected to the currency-network |
115 | 250 | 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 |
116 | 253 | 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 |
117 | 254 |
|
| 255 | + |
| 256 | + |
| 257 | + |
| 258 | +# Check the version of Docker Compose installed |
118 | 259 | docker-compose --version |
| 260 | + |
| 261 | +# Change directory to the microservices folder |
119 | 262 | cd ../../microservices/ |
| 263 | + |
| 264 | +# Start the services defined in the Docker Compose file |
120 | 265 | docker-compose up |
| 266 | + |
| 267 | +# Start the services defined in the Docker Compose file in detached mode |
121 | 268 | docker-compose up -d |
| 269 | + |
| 270 | +# List running containers |
122 | 271 | docker container ls |
| 272 | + |
| 273 | +# List Docker networks |
123 | 274 | docker network ls |
| 275 | + |
| 276 | +# Inspect a Docker network with a given network name |
124 | 277 | docker network inspect microservices_currency-compose-network |
| 278 | + |
| 279 | +# Stop the services defined in the Docker Compose file |
125 | 280 | docker-compose down |
| 281 | + |
| 282 | +# List all containers, including stopped ones |
126 | 283 | docker container ls -a |
| 284 | + |
| 285 | +# Remove all unused Docker resources |
127 | 286 | docker system prune -a |
| 287 | + |
| 288 | +# Validate the Docker Compose file |
128 | 289 | docker-compose config |
| 290 | + |
| 291 | +# List Docker images used by the services defined in the Docker Compose file |
129 | 292 | docker-compose images |
| 293 | + |
| 294 | +# List the running services defined in the Docker Compose file |
130 | 295 | docker-compose ps |
| 296 | + |
| 297 | +# Display the top resource-consuming processes of the services defined in the Docker Compose file |
131 | 298 | docker-compose top |
132 | 299 |
|
| 300 | + |
133 | 301 | ``` |
134 | 302 |
|
135 | 303 |
|
136 | | -``` |
| 304 | +```bash |
| 305 | +# Build a Docker image for a Java hello world application with a given tag |
137 | 306 | docker build -t in28min/hello-world-java:0.0.1.RELEASE . |
| 307 | + |
| 308 | +# Push the Docker image with the specified tag to a registry |
138 | 309 | docker push in28min/hello-world-java:0.0.1.RELEASE |
139 | 310 |
|
| 311 | + |
| 312 | + |
| 313 | + |
| 314 | +# Build a Docker image for a Python hello world application with a given tag |
140 | 315 | docker build -t in28min/hello-world-python:0.0.1.RELEASE . |
| 316 | + |
| 317 | +# Push the Docker image with the specified tag to a registry |
141 | 318 | docker push in28min/hello-world-python:0.0.1.RELEASE |
142 | 319 |
|
| 320 | + |
| 321 | + |
| 322 | + |
| 323 | +# Build a Docker image for a Node.js hello world application with a given tag |
143 | 324 | docker build -t in28min/hello-world-nodejs:0.0.1.RELEASE . |
| 325 | + |
| 326 | +# Push the Docker image with the specified tag to a registry |
144 | 327 | docker push in28min/hello-world-nodejs:0.0.1.RELEASE |
| 328 | + |
145 | 329 | ``` |
146 | 330 |
|
147 | 331 | ### Host Networking in Docker for Mac and Windows |
|
0 commit comments