-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-hello-world
executable file
·83 lines (43 loc) · 1.55 KB
/
01-hello-world
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
#!/bin/dash
docker container rm -f myAlpine
docker image rm -f alpine:3.11
clear
set -v
# We need to pull an image into our local catch.
docker image pull alpine:3.11
# Run the image in a container with
docker container run -it --rm --name myAlpine alpine:3.11
# we can override the default command (the default in Alpine is /bin/sh)
read x
docker container run -it --rm --name myAlpine alpine:3.11 ping -c 5 sun.com
# when finished the container closes down -- note --rm option
read x
# Container status
# Run a container in daemon mode,
docker container run -d --name myAlpine alpine /bin/sh -c 'trap exit TERM; while echo $(( i += 1));do sleep 5;done'
# container status: use the docker `container ls` and `docker container inspect ...` commands
docker container ls
docker container inspect --format '{{.State.Status}}' myAlpine
read x
# now stop the container
docker container stop myAlpine
docker container ls
read x
# So has the container gone? Let's look deeper
docker container inspect --format '{{.State.Status}}' myAlpine
read x
# use docker container ls -a instead
docker container ls -a
read x
# Use the command `docker container rm ....`
docker container rm myAlpine
docker container inspect --format '{{.State.Status}}' myAlpine
read x
# let's look at container logs
docker container run -d --name myAlpine alpine /bin/sh -c 'trap exit TERM; while echo $(( i += 1));do sleep 5;done'
read x
# let's look at the logs
docker container logs myAlpine
read x
# let's tail the logs (Ctrl-C to exit)
docker container logs --follow myAlpine