《循序渐进学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已经安装成功了。

相关文章
|
3天前
|
Ubuntu 数据安全/隐私保护
在UBUNTU虚拟机上安装R软件包
在UBUNTU虚拟机上安装R软件包
|
3天前
|
存储 编解码 Ubuntu
0-零基础安装ubuntu(超详细安装步骤)
0-零基础安装ubuntu(超详细安装步骤)
|
4天前
|
Ubuntu Linux 定位技术
手把手教你优雅的安装虚拟机 Ubuntu —— 图文并茂
手把手教你优雅的安装虚拟机 Ubuntu —— 图文并茂
|
7天前
|
时序数据库 Docker 容器
Docker安装InfluxDB
Docker安装InfluxDB
10 0
|
7天前
|
关系型数据库 MySQL 数据库
Docker安装MySQL
Docker安装MySQL
14 1
|
8天前
|
存储 Ubuntu 关系型数据库
Docker从入门到精通:ubuntu系统安装docker
本文介绍了Docker的安装过程。首先,文章简述了Docker的组成部分:镜像(如模板用于创建容器服务)、容器(运行应用的独立实体)和仓库(存储镜像的库)。接着,针对Ubuntu系统,详细阐述了卸载旧版本Docker、更新软件包、安装依赖、添加Docker官方GPG密钥和软件源、安装Docker以及配置用户组的步骤。最后,通过启动Docker、验证安装是否成功(运行`hello-world`镜像)和查看Docker版本来确认安装完成。
44 12
|
10天前
|
关系型数据库 MySQL 数据库
docker自定义安装mysql 5.7
docker自定义安装mysql 5.7
19 0
|
10天前
|
存储 Linux Shell
centos 部署docker容器 安装 、基本使用方法(一)
centos 部署docker容器 安装 、基本使用方法(一)
19 0
|
14天前
|
Ubuntu Python
WSL ubuntu 20.04安装python3
通过以上步骤,你可以在WSL的Ubuntu 20.04上成功安装Python 3。 买CN2云服务器,免备案服务器,高防服务器,就选蓝易云。百度搜索:蓝易云
15 1
|
14天前
|
Ubuntu Python
ubuntu安装python3.9
通过以上步骤,你可以在Ubuntu上成功安装Python 3.9。 买CN2云服务器,免备案服务器,高防服务器,就选蓝易云。百度搜索:蓝易云
18 1