[Docker入门-1] Docker CE for Ubuntu hello-world

更多内容: http://blog.codeye.top

环境

Ubuntu Server 16.04(LTS) amd64

卸载旧版本

sudo apt-get remove docker docker-engine docker.io containerd runc

It’s OK if apt-get reports that none of these packages are installed.

存储驱动

默认就行

安装Docker CE

1、更新包索引

sudo apt update

2、安装依赖包

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

[Docker入门-1] Docker CE for Ubuntu hello-world_第1张图片
3、添加Docker的官方GPG密钥

 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

通过搜索指纹的最后8个字符,验证您现在拥有带指纹的密钥

sudo apt-key fingerprint 0EBFCD88

[Docker入门-1] Docker CE for Ubuntu hello-world_第2张图片

4、Docker stable 稳定版本

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable" && apt-get update

[Docker入门-1] Docker CE for Ubuntu hello-world_第3张图片
[Docker入门-1] Docker CE for Ubuntu hello-world_第4张图片
5、通过运行hello-world 映像验证是否正确安装了Docker CE

sudo docker run hello-world

[Docker入门-1] Docker CE for Ubuntu hello-world_第5张图片

6、基本操作

  • 普通用户权限(eg. user:ubuntu)
  sudo usermod -aG docker ubuntu

在这里插入图片描述

Window10 下Linux子系统,Docker问题

ubuntu@DESKTOP-LJ47B6Q:~$ docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
ubuntu@DESKTOP-LJ47B6Q:~$ sudo systemctl start docker
[sudo] password for ubuntu:
System has not been booted with systemd as init system (PID 1). Can't operate.
ubuntu@DESKTOP-LJ47B6Q:~$

报错内容:

  • docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
  • System has not been booted with systemd as init system (PID 1). Can’t operate.

[Docker入门-1] Docker CE for Ubuntu hello-world_第6张图片
上图中相关指令:

export PATH="$HOME/bin:$HOME/.local/bin:$PATH"
export PATH="$PATH:/mnt/c/Program\ Files/Docker/Docker/resources/bin"
alias docker=docker.exe
alias docker-compose=docker-compose.exe
$ docker -H tcp://0.0.0.0:2376 images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
$ echo >> ~/.bashrc <
$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

文章链接:running-docker-on-bash-on-windows

你可能感兴趣的:(Docker)