YAZONG 我的开源

ubuntu18和centos7安装docker笔记

 
0 评论0 浏览

----ubuntu18

yalong@yalong-NUC8i7BEH:~#sudo apt-get remove docker docker-engine docker.io containerd runc

yalong@yalong-NUC8i7BEH:~#sudo apt-get update

yalong@yalong-NUC8i7BEH:~#sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

yalong@yalong-NUC8i7BEH:~#sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

yalong@yalong-NUC8i7BEH:~#sudo apt-get update

yalong@yalong-NUC8i7BEH:~#sudo apt-get install apt-transport-https ca-certificates software-properties-common curl

yalong@yalong-NUC8i7BEH:~#sudo curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

yalong@yalong-NUC8i7BEH:~#sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

yalong@yalong-NUC8i7BEH:~#sudo apt-get install docker-ce

yalong@yalong-NUC8i7BEH:~#sudo docker run hello-world
#出现下述内容,表示 docker 还没这个镜像,docker 要下载,这里要稍等一会,如果长时间不显示,那么可以多执行几次这个命令
Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:4fe721ccc2e8dc7362278a29dc660d833570ec2682f4e4194f4ee23e415e1064
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.
    (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/

yalong@yalong-NUC8i7BEH:~#sudo systemctl status docker
yalong@yalong-NUC8i7BEH:~#

sudo systemctl status docker

sudo systemctl enable docker

sudo systemctl start docker

----centos7

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum install docker-ce
systemctl status docker
systemctl start docker
systemctl status docker
docker run hello-world

参考网站:

http://www.docker.org.cn/book/

https://www.runoob.com/docker/ubuntu-docker-install.html


标题:ubuntu18和centos7安装docker笔记
作者:yazong
地址:https://blog.llyweb.com/articles/2019/12/29/1578146746449.html