返回文章列表文章索引阅读全文
STARBLOG / 阅读手记
系统配置

Ubuntu-16-04-Install-and-Configure-Docker

Install the relevant packages $ sudo apt-get update # Update the repository information first $ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common Add the repository Official repository # Add the official Docker GPG key (to verify the downloaded files)

曦远 (DealiAxy)约 10 分钟
目录9 个章节
$ sudo apt-get update # 先更新一下软件源库信息

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

Add Software Repository

Official Repository

# Add Docker's official GPG key (to verify the legitimacy of downloaded packages, the GPG key of the software source needs to be added)
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Set the apt repository address for the stable version
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

Alibaba Cloud repository

$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

$ sudo add-apt-repository \
     "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
     $(lsb_release -cs) \
     stable"

Install Docker

$ sudo apt-get update
$ sudo apt-get install docker-ce # Install the latest version of Docker

If you need to install a specific version, use the following commands:

$ apt-cache policy docker-ce # View all available Docker versions for installation
$ sudo apt-get install docker-ce=18.03.0~ce-0~ubuntu # Install a specific version of Docker

Check if Docker is installed successfully

$ docker --version # Check installed Docker version

## Adding Access Permissions

If you run Docker at this point as a non-root user, you will encounter an error:

```bash
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.26/images/json: dial unix /var/run/docker.sock: connect: permission denied

Let's check the permissions:

$ cd /var/run
$ ll | grep docker

Output is as follows

drwx------ 8 root root 180 Nov 21 16:36 docker -rw-r--r-- 1 root root 5 Nov 21 16:35 docker.pid srw-rw---- 1 root docker 0 Nov 21 16:35 docker.sock


As you can see, the owner of `docker.sock` is the `docker` group. Therefore, we need to add the current user to this group.

```bash
$ sudo gpasswd -a ${USER} docker

Restart Docker.

sudo service docker restart

Switch the current session to the new group or restart the X session.

newgrp - docker

Note: The last step is necessary. Otherwise, because the groups command retrieves cached group information, the newly added group information may not take effect, causing docker images to also throw an error.

Running Docker Tests

Now you can run the hello-world test~

$ docker run hello-world

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.
    (amd64)
 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 ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

That's all there is to the installation~

References

https://docs.docker.com/get-started/#test-docker-version https://www.jianshu.com/p/a12558da034e https://www.jianshu.com/p/95e397570896

_EOF_

Ubuntu-16-04-Install-and-Configure-Docker

本文作者:
程序设计实验室
版权声明:
本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!

相关文章

内存不够用?在Linux上使用swapfile配置交换空间

前言 几个月前我还兴高采烈写了篇文章说给笔记本升级了内存配置,从乞丐版的4G一跃成为16G高富帅,然而,这几个月来我备受电脑死机的折磨,我现在有理由怀疑我可能买了假的内存条,于是没有办法,只能换回原厂的4G内存条,~~(然后准备赚部台式机)~~,问题不大。 换上4G内存条之后效果显著,只开了一个谷歌浏览器,内存占用就已经到了80%了,JB家的IDE是决计不敢再用了,可是这样还是难以满足系统对内存空

2025-10-27 · 系统配置 · 约 1 分钟

给你的Deepin系统换主题~

我现在的桌面: 因为美国封锁然后华为电脑用上Deepin系统的事情,Deepin系统最近名声大噪,其实Deepin本来的界面就很好看,号称打造最适合国人的系统不是盖的。 不过Deepin有一个坏处,就是默认主题的标题栏太大了…… 太占空间。所以我们要换主题折腾一下。 Deepin的桌面是Qt写的,所以首先要换KDE主题,然后再安排一下GTK3的主题,在Deepin系统设置里面换的主题就是GTK的,

2025-10-01 · 系统配置 · 约 1 分钟

讨论

共 0 条

良言一句三冬暖,恶语伤人六月寒。

加载评论中…