mirror of
https://github.com/yeasy/docker_practice.git
synced 2024-11-24 07:23:38 +00:00
Update ubuntu to 18.04
This commit is contained in:
parent
4d38aaad3b
commit
af7663bd61
@ -118,7 +118,7 @@ RUN apt-get update && apt-get install -y \
|
||||
将 `apt-get update` 放在一条单独的 `RUN` 声明中会导致缓存问题以及后续的 `apt-get install` 失败。比如,假设你有一个 `Dockerfile` 文件:
|
||||
|
||||
```docker
|
||||
FROM ubuntu:14.04
|
||||
FROM ubuntu:18.04
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
@ -128,7 +128,7 @@ RUN apt-get install -y curl
|
||||
构建镜像后,所有的层都在 Docker 的缓存中。假设你后来又修改了其中的 `apt-get install` 添加了一个包:
|
||||
|
||||
```docker
|
||||
FROM ubuntu:14.04
|
||||
FROM ubuntu:18.04
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
|
@ -64,18 +64,25 @@ tutum/ubuntu Ubuntu image with SSH access. For the root.
|
||||
|
||||
根据搜索出来的结果,读者可以自行选择下载镜像并使用。
|
||||
|
||||
下面以 ubuntu 14.04 为例,演示如何使用该镜像安装一些常用软件。
|
||||
下面以 ubuntu 18.04 为例,演示如何使用该镜像安装一些常用软件。
|
||||
|
||||
首先使用 `-ti` 参数启动容器,登录 bash,查看 ubuntu 的发行版本号。
|
||||
|
||||
```bash
|
||||
$ docker run -ti ubuntu:14.04 /bin/bash
|
||||
root@7d93de07bf76:/# lsb_release -a
|
||||
No LSB modules are available.
|
||||
Distributor ID: Ubuntu
|
||||
Description: Ubuntu 14.04.1 LTS
|
||||
Release: 14.04
|
||||
Codename: trusty
|
||||
$ docker run -ti ubuntu:18.04 /bin/bash
|
||||
root@7d93de07bf76:/# cat /etc/os-release
|
||||
NAME="Ubuntu"
|
||||
VERSION="18.04.1 LTS (Bionic Beaver)"
|
||||
ID=ubuntu
|
||||
ID_LIKE=debian
|
||||
PRETTY_NAME="Ubuntu 18.04.1 LTS"
|
||||
VERSION_ID="18.04"
|
||||
HOME_URL="https://www.ubuntu.com/"
|
||||
SUPPORT_URL="https://help.ubuntu.com/"
|
||||
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
|
||||
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
|
||||
VERSION_CODENAME=bionic
|
||||
UBUNTU_CODENAME=bionic
|
||||
```
|
||||
|
||||
当试图直接使用 `apt-get` 安装一个软件的时候,会提示 `E: Unable to locate package`。
|
||||
|
@ -6,7 +6,7 @@
|
||||
```bash
|
||||
$ docker container ls -a
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
7691a814370e ubuntu:14.04 "/bin/bash" 36 hours ago Exited (0) 21 hours ago test
|
||||
7691a814370e ubuntu:18.04 "/bin/bash" 36 hours ago Exited (0) 21 hours ago test
|
||||
$ docker export 7691a814370e > ubuntu.tar
|
||||
```
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
例如,下面的命令输出一个 “Hello World”,之后终止容器。
|
||||
|
||||
```bash
|
||||
$ docker run ubuntu:14.04 /bin/echo 'Hello world'
|
||||
$ docker run ubuntu:18.04 /bin/echo 'Hello world'
|
||||
Hello world
|
||||
```
|
||||
|
||||
@ -20,7 +20,7 @@ Hello world
|
||||
下面的命令则启动一个 bash 终端,允许用户进行交互。
|
||||
|
||||
```bash
|
||||
$ docker run -t -i ubuntu:14.04 /bin/bash
|
||||
$ docker run -t -i ubuntu:18.04 /bin/bash
|
||||
root@af8bae53bdd3:/#
|
||||
```
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
```bash
|
||||
docker container ls -a
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
ba267838cc1b ubuntu:14.04 "/bin/bash" 30 minutes ago Exited (0) About a minute ago trusting_newton
|
||||
ba267838cc1b ubuntu:18.04 "/bin/bash" 30 minutes ago Exited (0) About a minute ago trusting_newton
|
||||
98e5efa7d997 training/webapp:latest "python app.py" About an hour ago Exited (0) 34 minutes ago backstabbing_pike
|
||||
```
|
||||
|
||||
|
@ -11,7 +11,6 @@ mongo 3.2 fe9198c04d62 5 days ago
|
||||
<none> <none> 00285df0df87 5 days ago 342 MB
|
||||
ubuntu 18.04 f753707788c5 4 weeks ago 127 MB
|
||||
ubuntu latest f753707788c5 4 weeks ago 127 MB
|
||||
ubuntu 14.04 1e0c3dd64ccd 4 weeks ago 188 MB
|
||||
```
|
||||
|
||||
列表包含了 `仓库名`、`标签`、`镜像 ID`、`创建时间` 以及 `所占用的空间`。
|
||||
@ -79,7 +78,6 @@ $ docker image ls ubuntu
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
ubuntu 18.04 f753707788c5 4 weeks ago 127 MB
|
||||
ubuntu latest f753707788c5 4 weeks ago 127 MB
|
||||
ubuntu 14.04 1e0c3dd64ccd 4 weeks ago 188 MB
|
||||
```
|
||||
|
||||
列出特定的某个镜像,也就是说指定仓库名和标签
|
||||
@ -151,5 +149,4 @@ fe9198c04d62 mongo 3.2
|
||||
00285df0df87 <none> <none>
|
||||
f753707788c5 ubuntu 18.04
|
||||
f753707788c5 ubuntu latest
|
||||
1e0c3dd64ccd ubuntu 14.04
|
||||
```
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
压缩包可以是本地文件、远程 Web 文件,甚至是从标准输入中得到。压缩包将会在镜像 `/` 目录展开,并直接作为镜像第一层提交。
|
||||
|
||||
比如我们想要创建一个 [OpenVZ](https://openvz.org/Main_Page) 的 Ubuntu 14.04 [模板](https://openvz.org/Download/template/precreated)的镜像:
|
||||
比如我们想要创建一个 [OpenVZ](https://openvz.org) 的 Ubuntu 14.04 [模板](https://openvz.org/Download/template/precreated)的镜像:
|
||||
|
||||
```bash
|
||||
$ docker import \
|
||||
|
Loading…
Reference in New Issue
Block a user