Skip to content

Commit 24eb615

Browse files
committed
Use latest version tools
1 parent 43e1205 commit 24eb615

File tree

15 files changed

+49
-56
lines changed

15 files changed

+49
-56
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![](https://img.shields.io/github/stars/yeasy/docker_practice.svg?style=social&label=Stars)](https://github.com/yeasy/docker_practice) [![](https://img.shields.io/github/release/yeasy/docker_practice/all.svg)](https://github.com/yeasy/docker_practice/releases) [![](https://img.shields.io/badge/Based-Docker%20CE%20v29.x-blue.svg)](https://github.com/docker/docker-ce) [![](https://img.shields.io/badge/Docker%20%E6%8A%80%E6%9C%AF%E5%85%A5%E9%97%A8%E4%B8%8E%E5%AE%9E%E6%88%98-jd.com-red.svg)][1]
44

5-
**v1.4.1**
5+
**v1.4.2**
66

77
| 语言 | - |
88
| :----------------------------------------------- | :------------------------------------------------- |

cases/os/debian.md

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,31 @@ Debian GNU/Linux 8
3232

3333
### 使用 Ubuntu 官方镜像
3434

35-
下面以 `ubuntu:18.04` 为例,演示如何使用该镜像安装一些常用软件。
35+
下面以 `ubuntu:24.04` 为例,演示如何使用该镜像安装一些常用软件。
3636

3737
首先使用 `-ti` 参数启动容器,登录 `bash`,查看 `ubuntu` 的发行版本号。
3838

3939
```bash
40-
$ docker run -ti ubuntu:18.04 /bin/bash
40+
$ docker run -ti ubuntu:24.04 /bin/bash
4141
root@7d93de07bf76:/# cat /etc/os-release
42+
PRETTY_NAME="Ubuntu 24.04 LTS"
4243
NAME="Ubuntu"
43-
VERSION="18.04.1 LTS (Bionic Beaver)"
44+
VERSION_ID="24.04"
45+
VERSION="24.04 LTS (Noble Numbat)"
46+
VERSION_CODENAME=noble
4447
ID=ubuntu
4548
ID_LIKE=debian
46-
PRETTY_NAME="Ubuntu 18.04.1 LTS"
47-
VERSION_ID="18.04"
4849
HOME_URL="https://www.ubuntu.com/"
4950
SUPPORT_URL="https://help.ubuntu.com/"
5051
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
51-
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
52-
VERSION_CODENAME=bionic
53-
UBUNTU_CODENAME=bionic
5452
```
5553

5654
当试图直接使用 `apt-get` 安装一个软件的时候,会提示 `E: Unable to locate package`
5755

5856
```bash
5957
root@7d93de07bf76:/# apt-get install curl
6058
Reading package lists... Done
61-
Building dependency tree
59+
Building dependency tree... Done
6260
Reading state information... Done
6361
E: Unable to locate package curl
6462
```
@@ -67,25 +65,10 @@ E: Unable to locate package curl
6765

6866
```bash
6967
root@7d93de07bf76:/# apt-get update
70-
Get:1 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
71-
Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
72-
Get:3 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [7348 B]
73-
Get:4 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [823 kB]
74-
Get:5 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
75-
Get:6 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
76-
Get:7 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB]
77-
Get:8 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [31.0 kB]
78-
Get:9 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [835 kB]
79-
Get:10 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [13.5 kB]
80-
Get:11 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1344 kB]
81-
Get:12 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [186 kB]
82-
Get:13 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [1127 kB]
83-
Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1350 kB]
84-
Get:15 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [11.4 kB]
85-
Get:16 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [44.7 kB]
86-
Get:17 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [2496 B]
87-
Get:18 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [4252 B]
88-
Fetched 17.6 MB in 1min 25s (207 kB/s)
68+
Get:1 http://archive.ubuntu.com/ubuntu noble InRelease [256 kB]
69+
Get:2 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]
70+
...
71+
Fetched 25.8 MB in 8s (3215 kB/s)
8972
Reading package lists... Done
9073
```
9174

compose/demo/app/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.6-alpine
1+
FROM python:3.12-alpine
22
ADD . /code
33
WORKDIR /code
44
RUN pip install redis flask

compose/django.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ COPY . /code/
2323
第二步,在 `requirements.txt` 文件里面写明需要安装的具体依赖包名。
2424

2525
```bash
26-
Django>=2.0,<3.0
27-
psycopg2>=2.7,<3.0
26+
Django>=4.0,<5.0
27+
psycopg2-binary>=2.9,<3.0
2828
```
2929

3030
第三步,`docker-compose.yml` 文件将把所有的东西关联起来。它描述了应用的构成(一个 web 服务和一个数据库)、使用的 Docker 镜像、镜像之间的连接、挂载到容器的卷,以及服务开放的端口。
@@ -105,8 +105,8 @@ web_1 | Performing system checks...
105105
web_1 |
106106
web_1 | System check identified no issues (0 silenced).
107107
web_1 |
108-
web_1 | November 23, 2017 - 06:21:19
109-
web_1 | Django version 1.11.7, using settings 'django_example.settings'
108+
web_1 | November 23, 2024 - 06:21:19
109+
web_1 | Django version 4.2, using settings 'django_example.settings'
110110
web_1 | Starting development server at http://0.0.0.0:8000/
111111
web_1 | Quit the server with CONTROL-C.
112112
```
@@ -116,5 +116,5 @@ web_1 | Quit the server with CONTROL-C.
116116
你还可以在 Docker 上运行其它的管理命令,例如对于同步数据库结构这种事,在运行完 `docker compose up` 后,在另外一个终端进入文件夹运行以下命令即可:
117117

118118
```bash
119-
$ docker compose run web python manage.py syncdb
119+
$ docker compose run web python manage.py migrate
120120
```

compose/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if __name__ == "__main__":
4141
编写 `Dockerfile` 文件,内容为
4242

4343
```docker
44-
FROM python:3.6-alpine
44+
FROM python:3.12-alpine
4545
ADD . /code
4646
WORKDIR /code
4747
RUN pip install redis flask

container/daemon.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
如果不使用 `-d` 参数运行容器。
88

99
```bash
10-
$ docker run ubuntu:18.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
10+
$ docker run ubuntu:24.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
1111
hello world
1212
hello world
1313
hello world
@@ -19,7 +19,7 @@ hello world
1919
如果使用了 `-d` 参数运行容器。
2020

2121
```bash
22-
$ docker run -d ubuntu:18.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
22+
$ docker run -d ubuntu:24.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
2323
77b2dc01fe0f3f1265df143181e7b9af5e05279a884f4776ee75350ea9d8017a
2424
```
2525

@@ -32,7 +32,7 @@ $ docker run -d ubuntu:18.04 /bin/sh -c "while true; do echo hello world; sleep
3232
```
3333
$ docker container ls
3434
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
35-
77b2dc01fe0f ubuntu:18.04 /bin/sh -c 'while tr 2 minutes ago Up 1 minute agitated_wright
35+
77b2dc01fe0f ubuntu:24.04 /bin/sh -c 'while tr 2 minutes ago Up 1 minute agitated_wright
3636
```
3737

3838
要获取容器的输出信息,可以通过 `docker container logs` 命令。

container/import_export.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
```bash
77
$ docker container ls -a
88
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9-
7691a814370e ubuntu:18.04 "/bin/bash" 36 hours ago Exited (0) 21 hours ago test
9+
7691a814370e ubuntu:24.04 "/bin/bash" 36 hours ago Exited (0) 21 hours ago test
1010
$ docker export 7691a814370e > ubuntu.tar
1111
```
1212

container/run.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
例如,下面的命令输出一个 “Hello World”,之后终止容器。
1212

1313
```bash
14-
$ docker run ubuntu:18.04 /bin/echo 'Hello world'
14+
$ docker run ubuntu:24.04 /bin/echo 'Hello world'
1515
Hello world
1616
```
1717

@@ -20,7 +20,7 @@ Hello world
2020
下面的命令则启动一个 bash 终端,允许用户进行交互。
2121

2222
```bash
23-
$ docker run -t -i ubuntu:18.04 /bin/bash
23+
$ docker run -t -i ubuntu:24.04 /bin/bash
2424
root@af8bae53bdd3:/#
2525
```
2626

container/stop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
```bash
1212
$ docker container ls -a
1313
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
14-
ba267838cc1b ubuntu:18.04 "/bin/bash" 30 minutes ago Exited (0) About a minute ago trusting_newton
14+
ba267838cc1b ubuntu:24.04 "/bin/bash" 30 minutes ago Exited (0) About a minute ago trusting_newton
1515
```
1616

1717
处于终止状态的容器,可以通过 `docker container start` 命令来重新启动。

data_management/bind-mounts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ $ docker inspect web
6262
$ docker run --rm -it \
6363
# -v $HOME/.bash_history:/root/.bash_history \
6464
--mount type=bind,source=$HOME/.bash_history,target=/root/.bash_history \
65-
ubuntu:18.04 \
65+
ubuntu:24.04 \
6666
bash
6767

6868
root@2affd44b4667:/# history

0 commit comments

Comments
 (0)