Skip to content

Commit 1816767

Browse files
committed
get-started: fix/simplify the persisting data experiment
Signed-off-by: David Karlsson <[email protected]>
1 parent 1ee6f44 commit 1816767

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

content/get-started/workshop/05_persisting_data.md

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,37 @@ changes won't be seen in another container, even if they're using the same image
2121

2222
### See this in practice
2323

24-
To see this in action, you're going to start two containers. In one container, you'll create a file. In the other container, you'll verify the file exists.
25-
What you'll see is that the file created in one container isn't available in another.
24+
To see this in action, you're going to start two containers. In one container,
25+
you'll create a file. In the other container, you'll check whether that same
26+
file exists.
2627

27-
1. Start an Alpine container and access its shell.
28+
1. Start an Alpine container and create a new file in it.
2829

2930
```console
30-
$ docker run -ti --name=mytest alpine
31+
$ docker run --rm alpine touch greeting.txt
3132
```
3233

33-
2. In the container, create a `greeting.txt` file with `hello` inside.
34+
> [!TIP]
35+
> Any commands you specify after the image name (in this case, `alpine`)
36+
> are executed inside the container. In this case, the command `touch
37+
> greeting.txt` puts a file named `greeting.txt` on the container's filesystem.
3438

35-
```console
36-
/ # echo "hello" > greeting.txt
37-
```
38-
39-
3. Exit the container.
40-
41-
```console
42-
/ # exit
43-
```
44-
45-
4. Run a new Alpine container and use the `cat` command to verify that the
46-
file does not exist.
39+
2. Run a new Alpine container and use the `stat` command to check whether the file exists.
4740
4841
```console
49-
$ docker run alpine cat greeting.txt
42+
$ docker run --rm alpine stat greeting.txt
5043
```
5144

5245
You should see output similar to the following that indicates the file does not exist in the new container.
5346

5447
```console
55-
cat: can't open 'greeting.txt': No such file or directory
48+
stat: can't stat 'greeting.txt': No such file or directory
5649
```
5750

58-
5. Go ahead and remove the containers using `docker ps --all` to get the IDs,
59-
and then `docker rm -f <container-id>` to remove the containers.
60-
51+
The `greeting.txt` file created by the first container did not exist in the
52+
second container. That is because the writeable "top layer" of each container
53+
is isolated. Even though both containers shared the same underlying layers that
54+
make up the base image, the writable layer is unique to each container.
6155

6256
## Container volumes
6357

0 commit comments

Comments
 (0)