《循序渐进学Docker》——3.3 在Ubuntu下安装Docker

简介: 本节书摘来自华章出版社《循序渐进学Docker》一书中的第3章,第3.3节,作者李金榜 尹烨 刘天斯 陈纯,更多章节内容可以访问云栖社区“华章计算机”公众号查看。 3.3 在Ubuntu下安装Docker 通过GNU GRUB选择进入Ubuntu系统,配置好网络。

本节书摘来自华章出版社《循序渐进学Docker》一书中的第3章,第3.3节,作者李金榜 尹烨 刘天斯 陈纯,更多章节内容可以访问云栖社区“华章计算机”公众号查看。

3.3 在Ubuntu下安装Docker

通过GNU GRUB选择进入Ubuntu系统,配置好网络。

先通过下面命令更新一下apt软件源。

sudo apt-get update

安装Docker有两种方式。

方法一:从apt源安装docker.io,但版本比较旧。

sudo apt-get install docker.io

方法二:使用官方提供的安装脚本,可以安装最新版本的Docker,推荐使用这种安装方式,安装命令如下:

sudo apt-get install curl
curl -sSL https://get.docker.com/ | sh

安装完成后,通过如下命令启动Docker的守护进程。

$ sudo service docker start
docker start/running. process 3050

然后,可以通过如下脚本检查Docker安装是否成功。

$ sudo docker run hello-world
Unable to f?ind image 'hello-world:latest' locally
latest: Pulling from library/hello-world
03f4658f8b78: Pull complete 
a3ed95caeb02: Pull complete 
Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/userguide/

如果不想每次运行Docker都使用sudo权限,可以把用户加到Docker组中。例如,我的用户名为harney,则添加命令如下:

$ sudo usermod -aG docker harney

重启后生效,再次执行Docker的指令,直接输入“docker ××”,不需要加“sudo”了。

现在在Ubuntu下的Docker已经安装成功了。

相关文章
|
4天前
|
Ubuntu Linux Python
Linux(15)Ubuntu安装ninja构建工具
Linux(15)Ubuntu安装ninja构建工具
15 0
|
1天前
|
运维 Linux 虚拟化
Docker详解(三)——Docker安装与部署
Docker详解(三)——Docker安装与部署
30 4
|
3天前
|
Ubuntu Linux 测试技术
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试(下)
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试
35 1
|
3天前
|
Linux 开发工具 Android开发
Docker系列(1)安装Linux系统编译Android源码
Docker系列(1)安装Linux系统编译Android源码
6 0
|
4天前
|
Ubuntu Linux 数据安全/隐私保护
Linux(7)Ubuntu20.04 arm64安装Docker
Linux(7)Ubuntu20.04 arm64安装Docker
18 0
|
4天前
|
存储 Ubuntu Docker
如何在 Ubuntu 上安装 Docker?
【4月更文挑战第17天】
42 8
如何在 Ubuntu 上安装 Docker?
|
1月前
|
Ubuntu Docker 容器
如何在Ubuntu上安装Docker?
【2月更文挑战第10天】
257 0
|
5月前
|
Ubuntu 网络安全 Docker
Ubuntu 安装与配置ssh (docker)
Ubuntu 安装与配置ssh (docker)
116 0
|
5月前
|
Docker 容器
Ubuntu22 debian 安装docker
Ubuntu22 debian 安装docker
118 0
|
7天前
|
Ubuntu Docker 索引
ubuntu 20.04 安装docker教程和安装中遇到的问题解决方案(超详细 附加图文教程)
ubuntu 20.04 安装docker教程和安装中遇到的问题解决方案(超详细 附加图文教程)
30 0